Frames

Frames give you the ability to show two or more documents at one time within one browser window. This feature allows you to be creative in how you present material. It is also useful in that it can keep portions of your documentation available while others are retrieved, especially if you organize your source material effectively within the frames.

Frames, though originally considered a Netscape-only feature, have gained support in many other browsers (such as Microsoft's Internet Explorer and Oracle's PowerBrowser, just to name a few).

Frame Document

A Frame Document has a basic structure very much like any HTML document, except the BODY element is replaced by a FRAMESET container, in which are defined frames, each of which can include its own, separate HTML document.

A FRAME element within the initial FRAMESET outlines the content and properties of a specific frame, while nested FRAMESET elements can be used to divide a frame into additional sub-frames, and so on. FRAME elements are empty, meaning they do not need a closing </FRAME> tag.

NOFRAMES can be used to designate BODY elements and content that can be read by browsers that do not recognize the FRAMESET elements. Browsers that understand the FRAMESET will ignore anything within the NOFRAMES element. A similar way to effect this is to place a BODY element within the document after the main FRAMESET element.

Here is an example of a Frame Document:

<HTML>
<HEAD>
<TITLE>Frames Example</TITLE>
</HEAD>

<FRAMESET ROWS="40%,60%">

<FRAME SRC="frame_one.html">
<FRAME SRC="frame_two.html">

<NOFRAMES>

<BODY>
You need a Frames-capable browser to view this page. Sorry!
</BODY>

</NOFRAMES>

</FRAMESET>

</HTML>
The initial FRAMESET designates how many frames will appear in the Frame Document through the ROWS attribute. This creates two frames, one on top of another. This format is used for however many frames are set up. There is also a COLS attribute for specifying frame columns.

You can specify a percentage, pixel count, or use the asterisk (*) as a wild card, allowing the browser to fill the remaining space correctly. Three columns that specify 75 pixel-width to the first frame, 33% for the second, and whatever is left over to the third, is formatted as <FRAMESET COLS="75,33%,*">.

Here's a semi-real world example, giving frames to the Introduction to HTML pages:

<HTML>
<HEAD>
<TITLE>Introduction to HTML - Frames version</TITLE>
</HEAD>

<FRAMESET COLS="24%,*">

<FRAME SRC="f_menu.html" MARGINHEIGHT="20" NORESIZE >
    <FRAMESET ROWS="45,*">
    <FRAME SRC="f_hedr.html" NAME="menu" MARGINWIDTH="20"
    SCROLLING="no">
    <FRAME SRC="f_intro.html" NAME="read">
    </FRAMESET>

<NOFRAMES>

<BODY>
No Frames, no gain!
</BODY>

</NOFRAMES>

</FRAMESET>

</HTML>
(Go to Introduction to HTML in Frames)

Additional FRAME attributes shown here include:

  • NAME. The A and BASE TARGET attribute use it to specify a frame as a target for a link.
  • SCROLLING specifies the status of the scroll bars; the default is "yes".
  • NORESIZE informs the browser the frame sized is fixed, and cannot be readjusted by the user.
  • MARGINWIDTH determines the margins in pixels for the left/right sides of a frame.
  • MARGINHEIGHT determines the margins in pixels for the top/bottom of a frame.


    Back to Tables
    Index

    Back to the Ziplink 101 page       ©2000 ZipLink. All Rights Reserved.