Monday, December 1, 2008

Anatomy of a DOCTYPE

An Explanation of the DOCTYPE Identifier
A typical DOCTYPE you might see on an HTML document is the HTML 4.01 transitional DOCTYPE. The DOCTYPE isn't exactly an HTML tag or XHTML element. Instead it is a declaration and always appears at the very top of your documents.

A DOCTYPE is made up of the following parts:
  • !DOCTYPE
    The identifier. It indicates to the user-agent that the enclosed information will define the type of document of the page.
  • HTML
    The Top Element. This tells the browser what element to expect as the top-level element. For HTML and XHTML documents this element would be <html>
  • PUBLIC
    The Availability. The most common DOCTYPES you will use will be publicly available - "PUBLIC". But you can also specify a local DTD with the "SYSTEM" key word.
  • "-//W3C//DTD HTML 4.01 Transitional//EN"
    The Formal Public Identifier. This entire string is what identifies the DOCTYPE.
The FPI is made up of these parts:
  • -
    Registration. If there is a plus-sign (+) here, that means that the organization is registered with the ISO. A minus-sign (-) indicates that it is not registered.
  • W3C
    The Organization. This is the group that owns and maintains the DOCTYPE being used.
  • DTD
    The Type. This defines the type of DOCTYPE used.
  • HTML 4.01 Transitional
    The Human-Readable Label. This is the label that tells you what DTD is being used. It is written so that humans, rather than computers, can understand it.
  • EN
    The Language. This is the language that the DTD is written in. It is not the language of the content of the page.
The rest of the DOCTYPE identifier is optional:
  • "http://www.w3.org/TR/html4/loose.dtd"
    The URI. This is an optional URL indicating where the DTD for this DOCTYPE can be found.
http://webdesign.about.com/od/dtds/qt/tipdoctype.htm

No comments: