The Web Design Group

FRAME - Frame

Syntax <FRAME>
Attribute Specifications
  • NAME=CDATA (name of frame)
  • SRC=URI (content of frame)
  • LONGDESC=URI (long description of frame)
  • FRAMEBORDER=[ 1 | 0 ] (frame border)
  • MARGINWIDTH=Pixels (margin width)
  • MARGINHEIGHT=Pixels (margin height)
  • NORESIZE (disallow frame resizing)
  • SCROLLING=[ yes | no | auto ] (ability to scroll)
  • core attributes
Contents Empty
Contained in FRAMESET

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.

The SRC attribute provides the URI of the frame's content, which is typically an HTML document. If the frame's content is an image, video, or similar object, and if the object cannot be described adequately using the TITLE attribute of FRAME, then authors should use the LONGDESC attribute to provide the URI of a full HTML description of the object.

For better accessibility to disabled users and better indexing with search engines, authors should not use an image or similar object as the content of a frame. Rather, the object should be embedded within an HTML document to allow the indexing of keywords and easier provision of alternate content.

The NAME attribute gives a name to the frame for use with the TARGET attribute of the A, AREA, BASE, FORM, and LINK elements. The NAME attribute value must begin with a character in the range A-Z or a-z.

The NAME should be human-readable and based on the content of the frame since non-windows browsers may use the NAME as a title for presenting a list of frames to the user. For example, NAME=left would be inappropriate since it says nothing about the content while NAME=nav would be inappropriate since it is not very human-readable. More suitable would be NAME=Content and NAME=Navigation. The TITLE attribute can also be used to provide a slightly longer title for the frame, though this is not widely supported by current browsers.

An example follows:

<FRAMESET ROWS="*,100">
  <FRAMESET COLS="40%,*">
    <FRAME NAME="Menu" SRC="nav.html" TITLE="Menu">
    <FRAME NAME="Content" SRC="main.html" TITLE="Content">
  </FRAMESET>
  <FRAME NAME="Ad" SRC="ad.html" TITLE="Advertisement">
  <NOFRAMES>
    <BODY>
      <H1>Table of Contents</H1>
      <UL>
        <LI>
          <A HREF="reference/html40/">HTML 4 Reference</A>
        </LI>
        <LI>
          <A HREF="reference/wilbur/">HTML 3.2 Reference</A>
        </LI>
        <LI>
          <A HREF="reference/css/">CSS Guide</A>
        </LI>
      </UL>
      <P>
        <IMG SRC="ad.gif" ALT="Ad: Does your bank charge too much?">
      </P>
    </BODY>
  </NOFRAMES>
</FRAMESET>

The FRAME element also accepts a number of attributes to specify the presentation on visual browsers. Style sheets provide a more flexible method of defining the presentation of frames, but the element's presentational attributes are more widely supported.

The FRAMEBORDER attribute specifies whether or not the frame has a visible border. The default value, 1, tells the browser to draw a border between the frame and all adjoining frames. The value 0 indicates that no border should be drawn, though borders from other frames will override this.

To fully remove the border, some browsers also require the use of other, non-standard attributes. See How do I remove the border around frames? for more details.

Note that removing the border of a frame takes away the user's ability to resize the frame on most browsers.

The MARGINWIDTH and MARGINHEIGHT attributes define the number of pixels to use as the left/right margins and top/bottom margins, respectively, within the frame. The value must be non-negative.

The boolean NORESIZE attribute prevents the user from resizing the frame. This attribute should never be used in a user-friendly Web site.

The SCROLLING attribute specifies whether scrollbars are provided for the frame. The default value, auto, generates scrollbars only when necessary. The value yes gives scrollbars at all times, and the value no suppresses scrollbars--even when they are needed to see all the content.

More Information