Lesson-7 (Frames)

The browser shows the web page through a window. We scroll the web page and see the entire document through the window of the browser. The window is called a container. It is possible to divide the container into several frames, and use each frame for displaying a different HTML document. Frames have the following characteristics.

  7.1 Frameset Definition

A set of frames is defined using the <frameset> tag which ends with the </frameset> tag. The <frameset> tag has two attributes.

If the frame are column-wise as shown in the Fig. 7.1, we must use the cols attribute. If the frames are row-wise as shown in Fig. 7.2, we must use the rows attribute.
Fig. 7.1 Column-wise Frame
Frame 1Frame 2Frame 3Frame 4
Fig. 7.2 Row-wise Frame
Frame 1
Frame 2
Frame 3
The sizes of the frames are mentioned in any one of the following units:

7.1.1 Pixel Unit

The pixel unit simply represents the number of pixels (Picture Elements) in each frame. Commas must seperate the numbers. For example, consider the following:
<frameset cols="150,70,70">
.......
.......
</frameset>
This definition creates three column-wise frames, with the first frame of 150 pixels width, the second of 70 pixels width and third also of 70 pixels width.

7.1.2 Percentage Unit

The percentage divides the window according to the specified percentages. For example, consider the frameset definition:
<frameset rows=70%,30%>
.......
.......
</frameset>
In the above definition, two row-wise frames are defined in the container. The first frame has 70% of the container and second one has 30% of the container. This is illustrated in Fig 7.3.

Size of Frames <Frameset Rows=70%,30%>
Frame 1 (70%)
Frame 2 (30%)

If the total percentage is greater than 100%, all percentage are scaled down. If the sum of the percentage is less than 100, the extra spaces are left out.

7.1.3 Fraction Unit

Instead of using Pixel or Percentage units, we can use the fraction units to represent the relative sizes of the frames. Suppose we give the following:
<frameset cols="4*,4*,*,*">
.......
.......
</frameset>
This defines four column-wise frames as shown in Fig. 7.4. The first two frames have size of four units each, and the third and fourth ones have one unit each. So the frame sizes are 4/10,4/10,1/10 and 1/10 of the container size.

Size of Frames <Frameset cols=4*,4*,*,*>
4/104/101/101/10

  7.2 Frame Definition

The definition of the frame is given using <frame> tag. The <frame> tag may have any of the following attributes: