HTML/Top Level Elements

From The Ultimate Programming Reference


Contents

FRAMESET

Frameset

Attributes

  • ROWS=MultiLengths (row lengths)
  • COLS=MultiLengths (column lengths)
  • ONLOAD=Script (all frames have been loaded)
  • ONUNLOAD=Script (all frames have been removed)
  • core attributes

Contents

One or more FRAMESET and FRAME elements, as well as an optional NOFRAMES

Contained in

HTML

Discription

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 to provide alternate content for browsers that do not support frames or have frames disabled. A meaningful NOFRAMES element should always be provided and should at the very least contain links to the main frame or frames.

The ROWS and COLS attributes define the dimensions of each frame in the set. Each attribute takes a comma-separated list of lengths, specified in pixels, as a percentage, or as a relative length. A relative length is expressed as i* where i is an integer. For example, a frameset defined with ROWS="3*,*" (* is equivalent to 1*) will have its first row allotted three times the height of the second row.

The values specified for the ROWS attribute give the height of each row, from top to bottom. The COLS attribute gives the width of each column from left to right. If ROWS or COLS is omitted, the implied value for the attribute is 100%. If both attributes are specified, a grid is defined and filled left-to-right then top-to-bottom.

The following example sets up a grid with two rows and three columns:

<FRAMESET ROWS="70%,30%" COLS="33%,33%,34%">
  <FRAME NAME="Photo1" SRC="Row1_Column1.html">
  <FRAME NAME="Photo2" SRC="Row1_Column2.html">
  <FRAME NAME="Photo3" SRC="Row1_Column3.html">
  <FRAME NAME="Caption1" SRC="Row2_Column1.html">
  <FRAME NAME="Caption2" SRC="Row2_Column2.html">
  <FRAME NAME="Caption3" SRC="Row2_Column3.html">
  <NOFRAMES>
    <BODY>
      <H1>Table of Contents</H1>
        <UL>
          <LI>
            <A HREF="Row1_Column1.html">Photo 1</A>
            (<A HREF="Row2_Column1.html">Caption</A>)
          </LI>
          <LI>
            <A HREF="Row1_Column2.html">Photo 2</A>
            (<A HREF="Row2_Column2.html">Caption</A>)
          </LI>
          <LI>
            <A HREF="Row1_Column3.html">Photo 3</A> 
           (<A HREF="Row2_Column3.html">Caption</A>)
          </LI>
      </UL> 
   </BODY>
  </NOFRAMES>
</FRAMESET>

The next example features nested FRAMESET elements to define two frames in the first row and one frame in the second row:

<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.0 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>

When pixel lengths are used, they should always be combined with a relative length to handle various window sizes. Pixel lengths should only be used when the frame consists primarily of images or other objects with a fixed size in pixels. Due to their ability to adapt to different window sizes, percentages and relative lengths are generally preferred. The FRAMESET element also accepts ONLOAD and ONUNLOAD attributes to specify client-side scripting actions to perform when the frames have all been loaded or removed.


BODY

Document Body

Attributes

  • BACKGROUND=URI (background image for document)
  • BGCOLOR=Color (background color for document)
  • TEXT=Color (text color for document)
  • LINK=Color (link color for document)
  • VLINK=Color (visited link color for document)
  • ALINK=Color (active link color for document)
  • ONLOAD=Script (document has been loaded)
  • ONUNLOAD=Script (document has been exited)
  • common attributes

Contents

In HTML 4.0 Strict: one or more block-level elements or SCRIPT, INS, DEL In HTML 4.0 Transitional: inline elements, block-level elements, INS, DEL

Contained In

In HTML 4.0 Strict or Transitional: HTML In HTML 4.0 Frameset: NOFRAMES

Discription

The BODY element contains the document body. BODY is required in non-frames documents, but its start and end tags are always optional. In frames documents, BODY must be contained within the NOFRAMES element, if NOFRAMES is used. The BODY element contains the document's content. The content should be contained within block-level elements or SCRIPT elements, though HTML 4.0 Transitional also allows inline elements directly within BODY.

BODY takes a number of attributes for specifying the background and colors of the document on visual browsers. These attributes are deprecated in HTML 4.0 in favor of style sheets, which provide greater flexibility in suggesting the presentation of a document. BGCOLOR suggests a background color, TEXT suggests a text color, LINK suggests a link color, VLINK suggests a visited link color, and ALINK suggests an active link color (when the link is selected). If one of these attributes is given, then all of them should be included to ensure that the user's chosen colors do not interfere with those suggested in the <BODY> tag. Authors should not rely on the specified colors being used since browsers allow these colors to be overridden by the user.

The BACKGROUND attribute suggests a background image for tiling on the document canvas. To help ensure a readable document, the BGCOLOR, TEXT, LINK, VLINK, and ALINK attributes should always be included when BACKGROUND is given. The BGCOLOR will be used for those not loading images.

Style sheets allow more flexibility in suggesting a background image, including the ability to specify the position of the image, how the image is tiled, and whether the image should scroll with the document.

In addition to the core events common to most elements, BODY accepts the following event attributes for client-side scripting:

  • ONLOAD, when the document has been loaded;
  • ONUNLOAD, when the document is exited.

HTML

HTML Document Element

Attributes

  • VERSION=CDATA (HTML version)
  • internationalization attributes

Contents

In HTML 4.0 Strict and Transitional: HEAD followed by BODY In HTML 4.0 Frameset: HEAD followed by FRAMESET

Contained In

n/a : <HTML> is a top level element

Discription

The HTML element contains the HTML document, made up of the HEAD followed by the BODY, except in Frameset documents where the FRAMESET element replaces the BODY. The start and end tags of the HTML element are both optional.

The LANG attribute is typically set on the HTML element to specify the base language of the document. The language should be specified according to RFC 1766; examples include en for English, en-US for American English, and ja for Japanese.

The deprecated VERSION attribute specifies the Document Type Definition (DTD) that describes the document. This attribute should not be used since the DOCTYPE declaration makes it redundant.

Personal tools