computer
using software
internet
web development
intro content
<< ^^ >>

Frames

Frames allow you to display two or more separate HTML documents in the browser window. Each frame can then be updated or have new documents loaded into them from any of the frames. A Framed layout can be useful for such things as a table of contents.

A Framed structure is made up of at least two documents; one or more frame document(s) and one or more HTML documents. Frames are generated by two HTML elements, the <frameset> </frameset> and the <frame> </frame>. A <noframes> </noframes> element can also be include for browsers that don’t display frames or visitors that have turned off frames.

A Framed document has the same basic structure as any HTML document, except that a <frameset> container replaces the <body> container. The frameset describes the sub-HTML documents, or frames, that will make up the page.

No HTML should be included within the <frameset> ... </frameset> elements.

A sample frame document;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<title>A basic frame document</title>
</head>
<frameset rows="44,*" frameborder="0" framespacing="0" border="0">
<frame name="banner" src="banner.html" marginwidth="0" marginheight="0" noresize>
<frameset cols="150,*" frameborder="0" framespacing="0" border="0">
<frame name="nav" src="nav.html" scrolling="no">
<frame name="content" src="main.html" scrolling="auto">
</frameset>
</frameset>
<noframes>
<body>
<a href=”main.html”>Click here for the main page”</a>
</body>
</noframes>
</html>

top

The frameset element attributes include:

The frame element attributes include:

When creating a link you must always address the name of the frame that you want the document to appear in using the target=”” attribute. For example a link on the nav.html page that is meant to appear in the content frame would look like this;

<a href=”newdocument.html” target=”content”>New Document</a>

Without the target attribute the document will appear in the current frame.

To pop a framed document out of a frame use target=”_top”. The frameset of a document is considered it’s parent so to have a document appear in the frameset space use target=_parent”. To have the document appear in the current frame (default) use target=”_self”. To have the document appear in a new window use target=”_blank”. You can also reference the name of a currently open window using target=”open_window_name”.

Always use care when addressing another frameset document as the page can get quite messy if a framed document is accidentally opened within another framed document by a misplaced url or target.

top

Updated December 1, 2007

-------------------
Previous Document Extended Menu Next Document
[ Top ] [ Search ] [ Comment ] [ Contact ] [ Legal ] [ Correction ]
contact - © GrassRootsDesign 2004 - map