Search this site...

XHTML Document Type Definition (DTDs)

There are three kinds of standard XHTML DTDs:

  1. Strict
  2. Transitional (also called loose)
  3. Frameset

Each of these XHTML DTDs targets a different level of detail for XHTML. In other words, you can choose the kind of feature you want from the different features supported by these standard XHTML DTDs.

If your page, for instance, does not require an advanced feature of XHTML, you can use a minimal DTD. Keep in mind smaller DTDs result in faster validation, which in turn, results in a faster display of your web page.

See table 1 for a description for each of these standard XHTML DTDs. The strict DTD is the most efficient as it provides minimal XHTML language for creating web pages. So you might be thinking this is a very limited DTD and may not be of any use. Actually, as mentioned before, it is the most efficient DTD and enables a fastest validation of XHTML documents. The idea behind using a strict DTD is to use style sheets for display rather than presentation elements. Thus use of a strict DTD aims to separate presentation code from content.

The transitional adds more features than a strict DTD to a XHTML document. The support for more features increases the validation process when an XHTML document is displayed. Because a transitional DTD provides support for presentation elements, the transitional DTD can be used for converting HTML documents to XHTML. The transitional DTD does not include support for frames (which allows you to use a single browser window to display multiple web pages).

The third DTD, frameset, is a full-featured XHTML DTD. This DTD has support for what a transitional DTD offers plus support for frames. Because frameset DTD is the most complex, it is the slowest of three when it come to validating XHTML documents.

Table 1 summary of the three XHTML DTDs
XHTML DTD name Description
Strict The strict type DTD does not support any HTML presentation elements (such as <p>, <a>, <b>, etc.). This is the low-featured XHTML DTD.
Transitional The Transitional type DTD adds support for HTML presentation elements. That means you can use HTML elements (such as <p>, <a>, <b>, etc.) directly inside of your XHTML document. The Transitional DTD is a medium-featured XHTML DTD.
Frameset The Frameset type DTD adds support for frames. This is the most full-featured XHTML DTD.

Declaring an XHTML DTD

Declaring an XHTML DTD and namespace for an XHTML document is a straightforward; simply, place DTD declaration at the top of the document before the <html> root element. The following shows code for declaring strict DTD:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

You would use this declaration when you wan to use the strict DTD. The public attribute informs the browser that the document's DTD is a public standard hosted by the W3C (World Wide Consortium). The information enclosed by the quotation marks is called formal public identifier (or FPI). In this declaration, the FPI ("-//W3C//DTD XHTML 1.0 Strict//EN") tells the browser that the DTD is the W3's DTD for XHTML 1.0 in the English language. After the FPI, the actual web address of the DTD document is listed:

The following shows document type declaration for the transitional DTD:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

The document type definition for the frameset DTD is similar:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"

For an XHTML document to be valid, the document must include one of these declarations. As commented earlier, use the appropriate DTD for the required level of XHTML support.