Monday, December 14, 2009

DOCTYPE In Html

The doctype declaration should be the very first thing in an HTML document, before the tag.

The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in.

The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers can render the content correctly.

A typical DOCTYPE you might see on an HTML document is the HTML 4.01 transitional DOCTYPE. The DOCTYPE for HTML 4.01 Transitional documents looks like this:

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.

Parts of a DOCTYPE

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

No comments:

Post a Comment