Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

Using frames

Frames divide the screen into separate windows. Each of the windows can contain an HTML page. To use frames, you create an HTML page that tells the browser how to divide the screen into split windows. This document is known as the frame definition. This frame definition uses <frameset> and <frame> tags to divide the main window into rectangular frames (like panes in a window).

Note that this document only contains the information about the number and position of frames and the URL of the pages you want to display in them. You cannot add the text and pictures to the frame definition. Instead, you use the src attribute in each <frame> tag to specify the HTML page that contains the content (text and pictures) to fill the frames.

You could set up two frames on a single page and display the contents list in one frame and the content in another. For example:

<html>
<head>
<title>Ann's home page</title>
</head>
<frameset cols="25%,*">
<frame src="content.htm" name="contents">
<frame src="homepage.htm" name="main">
</frameset>
</html>

In this example, the cols attribute in the <frameset> tag specifies the width of the frames. The width of the first frame is 25% of the main window and the width of the second (given as an asterisk) uses whatever space is left in the main window.


The number of columns is determine by the number of values that you enter. Our example has two but if you want five columns, you must enter five values. Separate the values with a comma.

If you want to divide the main window horizontally rather than vertically, use the rows attribute instead of the cols attribute.

You can specify the size of the frame as a percentage or in pixels. If you enter an asterisk, the browser works out how big to make the column as a proportion of the space it has available.

The <frame> tags within the frameset tell the browser the name of the file or picture that you want to display. In our example, content.htm and homepage.htm files provide the content that you want to display in the two frames.

Frames have been very controversial. Some designer think frames are great, others think that anyone who uses them should be taken out and shot.