Sunday, July 6, 2008

HTML - Document Type Definition

In the last lesson, "HTML - An Introduction", we discussed briefly the origin of HTML, and what it is. As HTML has continued to evolve, it has become apparent that many pages write "bad" HTML. To counter this, and to help usher in XML as a standard, HTML 4.01 was upgraded in a sense to XHTML.

Briefly, I will explain a bit about XHTML, as it will become the new cornerstone for this tutorial series. XHTML stands for Extensible HyperText Markup Language. This is similar to HTML, with the addition of the word Extensible. XHMTL is intended to replace HTML. XHTML is not too different from HTML, so the transition for those who are familiar with it will be easy. For those unfamiliar with HTML, you should begin with XHTML. XHTML is defined as an XML application, so it is going to be more relevant for a longer time.

There are three main sections of an XHTML document. They are:

  1. The Document Type (DOCTYPE)
  2. The Head
  3. The Body

This lesson will focus on the DOCTYPE. In XHTML, there are three standard DOCTYPE options:

  • STRICT
  • TRANSITIONAL
  • FRAMESET

Most of you won't be building pages with frames, as they are somewhat out-dated. I will not cover the FRAMESET here. I will focus most on the TRANSITIONAL, since it is not as complicated as STRICT. I build my pages in STRICT, so if you want to try your hand at it, feel free.

Again, as I won't be focusing on the STRICT, I will mention it briefly here. The DOCTYPE for STRICT is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

The TRANSITIONAL type, which we will be focusing on, is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

This code doesn't change often, so you can just copy and paste from one document to the next. This should be at the top of each page, above the <HTML> tag.

Next lesson: XHTML tags.

No comments: