SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 HTML Online
Introduction
  Document Structure

Head Elements


Sponsored Links

Document Structure

Our first stop is a brief discussion on document structure. Most HTML authors recognize their document's contain a HEAD section and a BODY section, where the HEAD is information about the page, and the BODY contains the contents. However, many authors fail to include a third required component in their HTML document, the document type. Looking at most web pages (and admittedly, the pages on this site), you will notice that the document type is missing.

HTML 4.0 defines three different types of documents. Each of these document types refer to a DTD (document type definition) that defines the rules for a proper HTML document. Below lists the different document types as listed in the HTML 4.0 recommendation.

  • The HTML 4.0 Strict DTD includes all elements and attributes that have not been deprecated or do not appear in frameset documents. For documents that use this DTD, use this document type declaration:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
      "http://www.w3.org/TR/REC-html40/strict.dtd">
  • The HTML 4.0 Transitional DTD includes everything in the strict DTD plus deprecated elements and attributes (most of which concern visual presentation). For documents that use this DTD, use this document type declaration:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
      "http://www.w3.org/TR/REC-html40/loose.dtd">
  • The HTML 4.0 Frameset DTD includes everything in the transitional DTD plus frames as well. For documents that use this DTD, use this document type declaration:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"
      "http://www.w3.org/TR/REC-html40/frameset.dtd">

In summary, remember all HTML 4.0 documents consist of the following three sections:

  1. A declaration of the HTML version,
  2. A header containing the document's title and meta information (delimited by the HEAD element),
  3. a body containing the document's actual content. The body may be implemented by the BODY element or the FRAMESET element.

HTML Structure is Important

All HTML elements within a document should be properly contained and create a hierarchical tree. This means that HTML elements must be contained within other elements, and should never overlap. For example, the following is very common on the web but is actually not valid HTML:

<B>Welcome to <I>Scott's</B> Home Page</I>

The problem with the above HTML is that the B and the I element overlap and are not properly contained. Overlapping can usually be easily fixed:

<B>Welcome to <I>Scott's</I></B><I> Home Page</I>

We have rewritten the invalid overlapping to be proper HTML. This proper HTML more reliably produces the results expected by the original HTML. Since the first example with overlapping HTML is not valid, there are no assurances that a complaint browser will accept it. Overlapping and using improper HTML causes greater problems when combined with style sheets and scripting, since both of these use the structure and containment of elements to determine behavior and appearance.

Next we explore the <HEAD> element and what information can be specified about your document.

Next Stop - The Head Element

Copyright © 1997-2008 InsideDHTML.com, LLC. All rights reserved.