The XHTML DTD (Document Type Definitions)

All XHTML documents have three main parts:

  • DOCTYPE declaration
  • <head>
  • <body>

The DOCTYPE must be defined before anything else in the document.

Everything but the DOCTYPE declaration will look like HTML, XHTML just holds you to a few rules. That’s the beauty of XHTML!

There are three types of DTDs:

  • STRICT – It forces you to use clean markup when writing your web pages. You use CSS to define your presentation.
  • TRANSITIONAL – This allows you to mix regular HTML features with XHTML. This one seems to be the most commonly used on newer sites, probably because it’s flexible and compatible.
  • FRAMESET – This allows you to use HTML frames

These are some examples of implementing each DTD.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">