home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

HTML 4.0 Sourcebook
(Publisher: John Wiley & Sons, Inc.)
Author(s): Ian S. Graham
ISBN: 0471257249
Publication Date: 04/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


The HTML element declares the enclosed text to be an HTML document. In a standard document, HTML can directly contain only two elements: HEAD and BODY, while in a frame-document, HTML can directly contain the elements HEAD, FRAMESET, and NOFRAMES, but cannot directly contain a BODY. The optional LANG and DIR attributes specify the language used in the document, as well as the direction in which the text should be laid out on the display. The optional VERSION attribute takes as its value a URL that points to the DTD, which encodes the HTML version corresponding to the document. This attribute is not currently supported, and indeed is deprecated, since the DOCTYPE declaration (discussed earlier) contains exactly the same information. Two simple examples illustrating the use of HTML are:

<HTML>
    <HEAD>
    ... head content....
    </HEAD>
    <BODY>
    ... body content....
    </BODY>
</HTML>

<HTML>
    <HEAD>
    ... head content....
    </HEAD>
    <FRAMESET>
    ... frame document content
    </FRAMESET>
    <NOFRAMES>
    ... noframe content
    </NOFRAMES>
</HTML>

Frame documents and the FRAMESET, FRAME, and NOFRAMES elements are discussed in Chapter 7.

HEAD Element: Document Meta-information

Usage: <HEAD> ... </HEAD>
Can Contain: BASE, ISINDEX, LINK, META, SCRIPT, STYLE, TITLE
Can Be Inside: HTML
Attributes: DIR, LANG, PROFILE

HEAD contains general information about the document. This information is not displayed as part of the document text; consequently, only certain elements are appropriate within the HEAD. These elements (BASE, ISINDEX, LINK, META, SCRIPT, STYLE, and TITLE) can appear inside HEAD in any order. The only mandatory HEAD element is TITLE; all others are optional. All the head elements except TITLE, SCRIPT, and STYLE are empty.

The optional PROFILE attribute takes as its value a URL (or multiple space-separated URLs) pointing to a document containing metadata describing the document or the document collection. However, the format for such metadata documents is still being developed, so that this attribute is not in current use.

The division between the HEAD and the BODY is important, as there are mechanisms for retrieving just the information in the document HEAD. Since the HEAD is always much smaller than the body, this is faster than accessing an entire document and can be extremely useful for generating fast catalogs or indexes.

BODY Element: The Document Text Body

Usage: <BODY> ... </BODY>
Can Contain: ADDRESS, BLOCKQUOTE, CENTER, DIR, DIV, DL, FIELDSET, FORM, Hn, HR, [ISINDEX], MENU, NOFRAMES, NOSCRIPT, OL, P, PRE, TABLE, UL,
characters, character highlighting, A, APPLET, BASEFONT, BR, BUTTON, IFRAME, IMG, INPUT, LABEL, MAP, OBJECT, SCRIPT, SELECT, TEXTAREA
Can Be Inside: HTML
Attributes: CLASS, DIR, ID, LANG, STYLE, TITLE, standard event handlers,
onLoad, onUnload, (onBlur, onFocus: Netscape Navigator 3/4; Internet Explorer 4),
ALINK, BACKGROUND, BGCOLOR, LINK, TEXT, VLINK, (BGPROPERTIES, LEFTMARGIN, TOPMARGIN: Internet Explorer only), (MARGINHEIGHT, MARGINWIDTH: Netscape Navigator 4 only)

The BODY contains the document proper, as opposed to the meta-information found in the HEAD. Formally, the BODY should not directly contain text; instead, it should contain elements that in turn contain the text. Recall that BODY states simply “this is the body of the document” and supplies no additional meaning to its content. It is the job of elements nested within the BODY to organize the text and assign it meaning. This is accomplished by the elements that define headings, lists, addresses, paragraphs, and so on.

The contents of the HEAD and BODY are largely exclusive—elements that belong inside the HEAD do not belong inside the BODY, and vice versa.

BODY can take the optional default attributes such as CLASS and DIR, as well as the listed event-handling attributes (onClick, etc.): These attributes were described previously in the sections entitled “Important ‘Generic’ Attributes” and “‘Event-Handler’ Element Attributes.” HTML 4 supports several other attributes for specifying properties of the document body, such as the default text colors and page background properties. Some proprietary attributes are supported by Microsoft Internet Explorer. In general, these properties are better (and much more easily) specified by style sheets, as described in Chapter 7. Indeed, these attributes will likely be dropped in a future version of HTML, in favor of the style sheet approach.

ALINK=“#rrggbb” or “color” (optional) Specifies the color for text within active (i.e., selected) links. The default color varies from browser to browser (red with Netscape Navigator).
BACKGROUND=“url” (optional) Specifies the URL of an image file (generally GIF or JPEG) that should be used to tile, or wallpaper, the background of the browser window. A background acts like a watermark and scrolls with the text.
BGCOLOR=“#rrggbb” or “color” (optional) Specifies the background color for the display window, either as an RGB color value or as a named color. If a BACKGROUND image is also specified, the background will first be tiled with the BGCOLOR color, and then with the image. If the BACKGROUND image is transparent, the color behind the background is given by BGCOLOR.
BGPROPERTIES=“fixed” (optional; Internet Explorer only) Takes the single value “fixed,” which indicates a fixed (non-scrolling) background. The default is for the background to scroll with the text.
LINK=“#rrggbb” or “color” (optional) Specifies the color for text within unvisited hypertext links (the default is usually blue).
LEFTMARGIN=“pixels” (optional; Internet Explorer only)
MARGINWIDTH=“pixels” (optional; Netscape Navigator 4 only) Specifies, in pixels, the left and right margins to leave for the entire body of the document. If set to zero, the text will be flush with the left-hand border of the browser window. Netscape Navigator 3 and earlier always have a default margin, around 10 pixels in width.
TEXT=“#rrggbb” or “color” (optional) Specifies the default color for the document text (the default is black).
TOPMARGIN=“pixels” (optional; Internet Explorer only)
MARGINHEIGHT=“pixels” (optional; Netscape Navigator 4 only) Specifies, in pixels, the margin to leave at the top of the browser window. If set to zero, the text will be flush with the top window border. Netscape Navigator 3 and earlier always have a default margin, around 10 pixels in height.
VLINK=“#rrggbb” or “color” (optional) Specifies the color for text within previously visited hypertext links (the default is often a pale purple).

HEAD Meta-information Elements

There are only seven elements that can appear in the document HEAD. These elements (and their associated meanings/content) are shown in Table 6.8.

All these elements are empty, except for TITLE, SCRIPT, and STYLE. As you can tell by the descriptions, these elements provide information about the document, such as the title, the relationship to other documents, or a style sheet that should be applied to the document. To support older, less well-designed documents and software, the DTD actually allows ISINDEX and STYLE elements within the BODY. However, you are best advised to keep them within the head, where they belong.

BASE Element: Base URL

Usage: <BASE>
Can Contain: empty
Can Be Inside: HEAD
Attributes: HREF, TARGET


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.