Idocs Guide to HTML

Frames Tutorial

Let's look at a basic example of how frames work:

The frameset file... The frameset file is the file you point your browser to. The frameset file uses <FRAMESET ...> and <FRAME ...> to tell the browser to go get more files to put on the page.
tells the browser to go get these four files The browser goes out again and retrieves the files which will appear on the page.
and put them all on one page in separate rectangles ('frames'). The browser puts all the files on one page in separate rectangles ("frames"). The user never sees anything from the original frameset file.

Think of frames as creating a "table of documents" on the page. Like a table, a group of frames has rows and columns. Each cell of the table contains a document which is stored in a separate file. <FRAMESET ...> defines the beginning and end of the table, and how many rows and columns that table will have. <FRAME ...> defines what will go into each cell ("frame") of the table.

Let's look in more detail at the example above. The entire contents of basicframeset.html (the frameset file) look like this:

This code ... creates this page (here's the real thing)
<TITLE>A Basic Example of Frames</TITLE>

<FRAMESET ROWS="75%, *" COLS="*, 40%">
   <FRAME SRC="framea.html">
   <FRAME SRC="frameb.html">
   <FRAME SRC="framec.html">
   <FRAME SRC="framed.html">

   <H1>No Frames? No Problem!</H1>
   Take a look at our 
   <A HREF="basic.noframes.html">no-frames</A> 


Picture of a simple frameset

Here's a line-by-line explanation of each piece of code for the frames:

Start the "table of documents".

ROWS="75%, *"
The table should have two rows. The first row should take up 75% of the height of the page, the second should take up the rest.

COLS="*, 40%">
The table should also have two columns. The second column should take up 40% of the width of the page, the first column should take up the rest.

<FRAME SRC="framea.html">
<FRAME SRC="frameb.html">
<FRAME SRC="framec.html">
<FRAME SRC="framed.html">
Put the four files into the frames.

Every framed page should have a no-frames alternative. The <NOFRAMES> content should go inside the outermost <FRAMESET ...> tag, usually just before the last </FRAMESET>. The most efficicent method for no-frames content is to link to a page which is specifically designed for no-frames.

End the frameset.

There are several other aspects of frames to note from this example:

Copyright 1997-2002 Idocs Inc. Content in this guide is offered freely to the public under the terms of the Open Content License and the Open Publication License. Contents may be redistributed or republished freely under these terms so long as credit to the original creator and contributors is maintained.