LESSON 9: Frames

  1. What is a frame?
  2. Element FRAMESET.
  3. Element FRAME.
  4. Element NOFRAMES.
  5. Examples.

1. What is a frame?

HTML frames allow authors to present documents in subwindows. Subwindows provide a way to keep certain information visible, while other views are scrolled or replaced.

For example, right now the browser window is divided on three subwindows.
Go to Top


2. Element FRAMESET.

\..........Description

The FRAMESET element is a frame container for dividing a window into rectangular subspaces called frames.

In a Frameset document, the outermost FRAMESET element takes the place of BODY and immediately follows the HEAD.

The FRAMESET element contains one or more FRAMESET or FRAME elements, along with an optional NOFRAMES element.

\..........Syntax

<FRAMESET
    COLS="list"
    ROWS="list"
    BORDER="pixels"
    BORDERCOLOR="color"
    FRAMEBORDER="yes"|"no"
    FRAMESPACING="pixels">
.....
</FRAMESET>

\..........Attributes

Attribute Description
COLS="list" Defines a comma-separated list of widths for division of window on columns.

(For example, to divide the window on two columns 20% and 80% width, write COLS=(20%,80%) or COLS=(20%,*). The asterisk * replaces the remaining percentage to 100%.)
ROWS="list" Specifies the comma-separated list of heights for division of window on rows.

(For example, to divide the window on two rows 20% and 80% height, write ROWS=(20%,80%) or ROWS=(20%,*). The asterisk * replaces the remaining percentage to 100%.)
BORDER="pixels" Specifies the border width around frames.
BORDERCOLOR="color" Specifies the border color around frames. If omitted, the default color is gray.
FRAMEBORDER= "yes"
"no"
Specifies whether or not the frames have a visible border. If FRAMEBORDER="yes" the space between frames is filled with BORDERCOLOR, if FRAMEBORDER="no" the space between frames is left blank (white color).
FRAMESPACING="pixels" Specifies the space between frames.

Note:The attribute FRAMESPACING overrides the attribute BORDER, i.e. if FRAMESPACING="20" and BORDER="0", the space between frames is 20 pixels.

\..........Examples to see

Examples 1 and 2 demonstrate FRAMESET attributes.
Go to Top


3. Element FRAME.

\..........Description

The FRAME element defines a frame -- a rectangular subspace within a Frameset document.

Each FRAME must be contained within a FRAMESET that defines the dimensions of the frame.

\..........Syntax

<FRAME
    NAME="name"
    MARGINHEIGHT="pixels"
    MARGINWIDTH="pixels"
    BORDERCOLOR="color"
    FRAMEBORDER="yes"|"no"
    NORESIZE
    SCROLLING="yes"|"no"|"auto"
    SRC="URI">

\..........Attributes

Attribute Description
NAME="name" Specifies the name of the frame for use with the TARGET attribute of A element.
MARGINHEIGHT="pixels" Specifies the number of pixels to use as the top/bottom margins, within the frame.
MARGINWIDTH="pixels" Specifies the number of pixels to use as the left/right margins, within the frame.
BORDERCOLOR="color" Specifies the border color around the frame. If omitted, the default color is gray.
. This attribute overrides the same attribute of FRAMESET element.
FRAMEBORDER= "yes"
"no"
Specifies whether or not the frame has a visible border. If FRAMEBORDER="yes" the space between the frame and all adjoining frames is filled with BORDERCOLOR, if FRAMEBORDER="no" the space is left blank (white color).
NORESIZE Prevents the user from resizing the frame.
SCROLLING= "yes"
"no"
"auto"
Specifies whether scrollbars are provided for the frame.

yes - gives scrollbars at all times;

no - suppresses scrollbars--even when they are needed to see all the content;

auto - generates scrollbars only when necessary (the default value).
SRC="URI" Specifies the URI for the document to render in the frame.

Note: Click here for more information about URI's.

\..........Examples to see

Examples 1 and 3 demonstrate FRAME attributes.
Go to Top


4. Element NOFRAMES.

\..........Description

The NOFRAMES element contains content that should only be rendered when frames are not displayed.

NOFRAMES is typically used in a Frameset document to provide alternate content for browsers that do not support frames or have frames disabled.

NOFRAMES must contain a BODY element.

\..........Syntax

<NOFRAMES>
.....
</NOFRAMES>

Go to Top


5. Examples.

Choose an example and move below the text box to see the HTML code.

Example 1: Dividing the window on frames.
Example 2: FRAMESET attributes.
Example 3: FRAME attributes.
Preview
Go to Top