home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Book HomeWeb Design in a NutshellSearch this book

9.2. Setting Up an HTML Document

The standard skeletal structure of an HTML document according to the HTML 4.01 specification is as follows:

    <TITLE>Document Title</TITLE>
    Contents of Document...

This document has three components: a document type declaration (<!DOCTYPE>), the header section (<head>), and the body of the document (<body>).

The HTML standard requires that the entire document appear within the <html> container, but most browsers can properly display the contents of the document even if these tags are omitted. All HTML documents are made up of two main structures, the head (also called the "header") and the body. The exception to this rule is when the document contains a frameset in place of the body. For more information about framesets, see Chapter 14, "Frames".

9.2.1. The Document Type Declaration

In order to be valid (i.e., to conform precisely to the HTML standard), an HTML document needs to begin with a document type declaration that identifies the version of HTML that is used in the document. There are three distinct versions of HTML 4.01 (Strict, Transitional, and Frameset), each defined by a distinct document type definition (DTD). The DTD documents live on the W3C server at a stable URL.

The document's DTD is specified at the beginning of the document using the SGML declaration <!DOCTYPE> (document type). The remainder of the declaration contains two methods for pointing to DTD information: one a publicly recognized document, the other a specific URL in case the browsing device does not recognize the public identifier.


If you are following the Strict version of HTML 4.01 (the version that omits all deprecated and browser-specific tags), use this document type definition:


If your document includes deprecated tags, point to the Transitional DTD using this document type definition:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

If your document uses frames, then identify the Frameset DTD. The Frameset DTD is the same as the Transitional version (it includes deprecated yet supported tags), with the addition of frame-specific tags.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"

DOCTYPE and Standards-Compliant Browsers

Until recently, it was recommended that HTML documents begin with a DOCTYPE declaration, but it wasn't put to much practical use. That has changed, and now you can use DOCTYPE to make the latest browser versions live up to their full potential.

Netscape 6, Internet Explorer 6 (Windows), and Internet Explorer 5 (Mac) switch into a strict, standards-compliant mode when they detect a DOCTYPE specifying the Strict HTML 4.01 DTD. By placing this declaration at the beginning of your document, you can write your documents and style sheets according to the standards and have confidence that they will work the way they should in these latest browsers. This is a great way to get started using standards-compliant code right away.

If the DOCTYPE declaration is missing or set to Transitional, these browsers revert to their legacy behavior of allowing the nonstandard code, intricate hacks, and common workarounds that are common in current web authoring practices. This allows new browsers to display existing documents properly.

9.2.2. The Document Header

The header, delimited by the <head> tag, contains information that describes the HTML document. The head tag has no attributes of its own; it merely serves as a container for other tags that help define and manage the document's contents.

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.