HTML frames allow authors to present documents in multiple views.
Views may be independent windows or subwindows. Multiple views offer
designers a way to keep certain information visible, while other views
are scrolled or replaced. For instance, to use three frames: one for a
static banner, one for a navigation menu, and one for a main view that
can be scrolled though or replaced by clicking on an item in the
navigation frame.

An HTML document with frames has a different makeup than an HTML
document without frames. A standard document has one HEAD section and one BODY. A document with frames has a HEAD, and a FRAMESET in
place of the BODY.

The FRAMESET section of a document
specifies the layout of views in the main user agent window.

In addition, the FRAMESET section can contain
a NOFRAMES element to provide alternate content
for user agents that do not support frames or are configured not to display
frames. We discuss alternate content in more
detail below.

Elements that might normally be placed in the BODY element must not appear before the first
FRAMESET element or the FRAMESET will be ignored.

The FRAMESET element specifies the
layout of the main user window in terms of rectangular subspaces.

Rows and columns

Setting the rows attribute
defines the number of horizontal subspaces. Setting the cols attribute defines the number of vertical
subspaces. Both attributes may be set simultaneously to create a
grid.

If the rows attribute is not
set, each column extends the entire length of the page. If the cols attribute is not set, each row
extends the entire width of the page. If neither attribute is set, the
frame takes up exactly the size of the page.

These two attributes have values that are comma-separated lists of
lengths. A length may be absolute (given as a number of pixels or
a percentage of the screen) or a relative length, indicated by the
form "i*", where "i" is an integer. When allotting space to rows and
columns, user agents allot absolute lengths first, then divide up
remaining space among relative length rows or columns. The value
"*" is equivalent to "1*".

Views are created left-to-right for columns and top-to-bottom
for rows. When both attributes are specified, views are created
left-to-right in the top row, left-to-right in the second row, etc.

The first example divides the screen vertically in two (i.e., creates
a top half and a bottom half).

The next example creates three columns: the second has a fixed width
of 250 pixels (useful, for example, to hold an image with a known
size). The first receives 25% of the remaining space and the third 75%
of the remaining space.

For the next example, suppose the browser window is currently 1000
pixels high. The first view is allotted 30% of the total height (300
pixels). The second view is specified to be exactly 400 pixels high.
This leaves 300 pixels to be divided between the other two frames. The
fourth frame's height is specified as "2*", so it is twice as high as
the third frame, whose height is only "*" (1*). Therefore the third
frame will be 100 pixels high and the fourth will be 200 pixels high.

Absolute lengths that do not sum to 100% of the real available
space should be adjusted by the user agent. When underspecified,
remaining space should be allotted proportionally to each view. When
overspecified, each view should be reduced according to its specified
proportion of the total space.

Nested frame sets

Framesets may be nested to any level.

In the following example, the outer FRAMESET divides the available space into three
equal columns. The inner FRAMESET then
divides the second area into two rows of unequal height.

<FRAMESET cols="33%, 33%, 34%">
...contents of first frame...
<FRAMESET rows="40%, 50%">
...contents of second frame, first row......contents of second frame, second row...
</FRAMESET>
...contents of third frame...
</FRAMESET>

This attribute specifies the amount of space to be left between
the frame's contents in its left and right margins. The value must be
greater than one pixel. The default value depends on the user agent.

This attribute specifies the amount of space to be left between
the frame's contents in its top and bottom margins. The value must be
greater than one pixel. The default value depends on the user agent.

Decorating a frame

The following example illustrates the usage of the decorative FRAME attributes. We specify that frame 1 will
allow no scroll bars. Frame 2 will leave white space around its
contents (initially, an image file) and the frame will not be
resizeable. No border will be drawn between frames 3 and 4. Borders
will be drawn (by default) between frames 1, 2, and 3.

This attribute specifies the name of a target frame where a document
is to be opened.

By assigning a name to a frame via the name
attribute, authors can refer to it as the "target" of links defined by
other elements. The target attribute may be
set for elements that create links (A,
LINK), image maps (AREA), and forms (FORM).

This example illustrates how targets allow the dynamic modification of
a frame's contents. First we define a frameset in the document
frameset.html, shown here:

When many links in the same document designate the same target, it is
possible to specify the target once and dispense with the target attributes in each element. This is done
by setting the target attribute of the
BASE element.

We return to the previous example, this time factorizing the target
information by defining it in the BASE
element and removing it from the A elements.

The NOFRAMES element specifies content that
should be displayed only when frames are not being displayed. User
agents that support frames must only display the contents of a NOFRAMES declaration when configured not to
display frames. User agents that do not support frames must display
the contents of NOFRAMES in any case.

NOFRAMES can be used either in the FRAMESET section of a frameset document or directly in
the BODY of a document used within a
frameset.

Suppose we have a sample frameset defined in "top.html" that designates a
document ("main.html") and a special table of contents
("table_of_contents.html") related to the main document. Here is "top.html":

What happens when the user reads "top.html" and the user agent is not
displaying frames? The user won't see anything since we do not have a BODY in "top.html". If we insert
"table_of_contents.html" and "main.html" directly in a NOFRAMES element in the FRAMESET, we solve the problem of associating the two
documents, but we may cause user agents that support frames to retrieve the
same data twice: one copy associated with the frameset and one copy
inserted in the NOFRAMES.

It is more economical to include the table of contents at the top
of "main.html" within a NOFRAMES element:

The IFRAME element allows authors to insert
a frame within a block of text. Inserting an inline frame within a
section of text is much like inserting an object via the OBJECT element: they both allow you to insert an
HTML document in the middle of another, they may both be aligned with
surrounding text, etc.

The information to be inserted inline is designated by the src attribute of this element. The
contents of the IFRAME element, on
the other hand, should only be rendered by user agents that do not
support frames or are configured not to display frames.

For user agents that support frames, the following example will place
an inline frame surrounded by a border in the middle of the text.

<IFRAME src="foo.html" width="400" height="500"
scrolling="auto" frameborder="1">
[Your user agent does not support frames or is currently configured
not to display frames. However, you may visit
<A href="foo.html">the related document.</A>]
</IFRAME>

Inline frames may not be resized (and thus, they do not take the
noresize attribute).