Frames

Frames are used to divide up the real estate on a web page in such a way that separate pages can be placed into each part. Frequently they are used to set up a navigation bar that remains visible as the rest of the document changes.

An example
Frame example
Notice the navigation frame down the left and the division of the right side into a map with hotspots and a frame for content.

Problems with frames
Back and Forward buttons may not work as you think
View Source only shows source of initial document
URL in location field only refers to initial page

Sample Code
Below the code is given for a page with a frame that divides a page into a top menu and a second frame called "body". Notice that the <BODY> tag is replaced by the <FRAMESET> tag.
<HTML>
<HEAD>
<TITLE>Main Frame</TITLE>
</HEAD>
<frameset rows="15%,*">
<frame src="menu.htm">
<frame src="page1.htm" name="body">
</frameset>
<noframes>
      This page uses frames. To view w/o frames go to ...
</noframes>
</HTML>
Here is the code for the menu page. Notice that each linked page is placed in the frame whose name is "body".
<HTML>
<HEAD><TITLE>menu</TITLE></HEAD>
<BODY>
<center>
<a href="page1.htm" target="body">Page 1</a>
<a href="page2.htm" target="body">Page 2</a>
</center>
</BODY>
</HTML>
Here is the Menu navigation determined by the code above.
Attributes of the <frame> tag
SCROLLING: the choices are YES, AUTO, and NO
NORESIZE
MARGINHEIGHT and MARGINWIDTH: specify in pixels. These add space between the frame edge and text.

Special Targets
The TARGET attribute tells a link where to load a document. This is usually specified by giving the window or frame name. Here are several special target names.
target="_self": loads document in the current window or frame
target="_parent": loads document in the base frame that contains the <frameset> tag
target="_top": loads the document in a new window without a frame at the top of the page.
target="_blank": opens a new browser window.