HTML Iframes:

Some browsers support a new type of HTML document that is called a frame document. In a frame document, the body element is replaced by another element called FRAMESET element.

 

The frameset element

The frameset element can contain a frame, frameset and noframe elements. The frameset element can only be inside an html element. The frameset element uses COLS and ROWS attributes.

<frameset rows = “10%, 80%, 10%>

<frame scrolling = “no” SRC= “logo +buttonbar.html”>

<frameset cols= “20%, 80%>

<frame name= “navigation” SRC=”navigation.html”>

<frame name= “main” SRC=”main/start.html”>

</frameset>

<frame scrolling= “no” SRC = “credits.html”>

</frameset>

…….

In the above example the display is first divided into three rows. The top bottom rows are narrow and it has the non scrolling documents.

The middle row is also divided further into two columns, the first column take 20% width and the second column takes 80% width of the display window. They are using the name attribute and these frames are scrollable.

This element is used to define the layout of window frames within the browser window. The contents of the frame document are defined by the frame or frameset elements.

The frame element is used to describe the properties of a particular frame. While the additional frameset elements are used to divide the corresponding frames into additional sub frames. Each frame is a distinct viewing region that contains its own HTML document.

The only element that is allowed in a frameset element is NOFRAMES.

Note that the HTML document that contains a FRAMESET element cannot have the BODY content.

 

Layout and size of frames

A frameset element defines the layout and the size of the frame. This is specified by the COLS and ROWS attributes. The COLS attribute is used to indicate that the frames are laid inside a column. The COLS attribute is assigned a value that specifies the number and size of the columns. The ROWS attribute is used to indicate that the frames are laid in rows. It is also assigned a value that specifies the number and the size of the rows. The FRAMESET element can have only one of these attributes either ROWS or COLS, but cannot have both the attributes.

 

The Frame element

The frame element is an empty element. It is used as follows:

<FRAME>

The frame element can be inside a FRAMESET element only. The attributes that the frame element uses are as follows:

  • MARGINWIDTH
  • MARGINHEIGHT
  • NAME
  • NORESIZE
  • SCROLLING
  • SRC

This element is used to define the properties of the frames that are declared by the FRAMESET element. The attributes MARGINWIDTH, MARGINHEIGHT, NORESIZE, and SCROLLING are used to define the physical properties of the frame, whereas, the name attribute assigns a certain name to a frame. And the SRC attribute is used to insert the HTML document in the frame. The SRC attribute is necessary to be used with the frame element, otherwise the frame element will be considered as empty.


EXAMPLE

<frameset rows = “10%, 80%, 10%>

<frame scrolling = “no” SRC= “logo +buttonbar.html”>

<frameset cols= “20%, 80%>

<frame name= “navigation” SRC=”navigation.html”>

<frame name= “main” SRC=”main/start.html”>

</frameset>

<frame scrolling= “no” SRC = “credits.html”>

</frameset>

…….

In the above example the display is first divided into three rows. The top bottom rows are narrow and it has the non scrolling documents. The middle row is also divided further into two columns, the first column take 20% width and the second column takes 80% width of the display window. They are using the name attribute and these frames are scrollable.