2.2 Choosing a DTD

Below are the DOCTYPES to use depending on which version of (X)HTML is being used. All of these will trigger browsers to render in standards mode. Before we go into the DOCTYPES there are 3 basic categories available:

  • Strict : Intended for (new) pages written to the latest HTML and CSS standards.
  • Transitional : Intended for (older) pages that are making the transition to the new standards.
  • Frameset : Identical to transitional apart for the use of the <frameset> tag instead of the <body> tag.

HTML 4.01 - Strict, Transitional and Frameset

HTML 4.01 strict is a trimmed down version of HTML 4.01 focusing on structure over presentation. Deprecated elements and attributes (including most presentational attributes), frames, and link targets are NOT allowed and CSS should be used to style all elements.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

HTML 4.01 transitional supports all attributes of HTML 4.01, presentational attributes, deprecated elements, and link targets. It is intended for webpages that are making the transition to HTML 4.01 strict.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

HTML 4.01 frameset is identical to transitional except for the use of <frameset> over <body>.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">

XHTML 1.0 - Strict, Transitional and Frameset

XHTML 1.0 strict is for pages conforming to XHTML rules, using CSS for full separation between content and presentation.

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

XHTML 1.0 Transitional is for pages conforming to basic XHTML rules but that may still use some HTML presentational tags for the sake of viewers that don't support CSS.

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

XHTML 1.0 frameset is identical to transitional except for the use of the <frameset> tag over <body>.

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

XHTML 1.1

For XHTML 1.1 the DTD is very simple:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

HTML 5

And even simpler for HTML 5:

<!DOCTYPE HTML>