By using a certain DOCTYPE
(strict or transitional) you claim to have correctly implemented a certain (X)HTML flavor:
When you declare a DOCTYPE
, validators take you at your word. When you validate your pages, they check your code against the syntax that you claim to follow. If the markup fails to meet the standard, it gives you error messages.
In addition,most browsers have implemented doctype switching. They use the DOCTYPE
you declare to decide whether the browser should use Strict or Quirks mode when rendering the page. In Strict mode browsers strictly follow the CSS specification, while Quirks mode retains a few browser quirks that were common in the “bad old days” (before adherence to standards).
In general, you should opt for Strict Mode. A useful table from the Helsinki University of Technology tells you how the modern browsers interpret doctypes and allows you to select a cross-browser one. See also the A List Apart article Fixing your site with the right doctype
To fully understand the differences between Strict and Quirks Mode, study the documentation pages:
- Mozilla Quirks Mode Behavior
- CSS Enhancements in Internet Explorer 6 (Explorer 5 only supports Quirks Mode)
- The Opera 7 DOCTYPE Switches
There is no official list for Explorer 5 on Mac, but CSS guru Eric Meyer has summarized the differences. Safari follows Mozilla.
Despite doctype switching, selecting an (X)HTML flavor remains the most important function of a DOCTYPE
. Which flavor do you feel comfortable with? Old-fashioned HTML or the newer XHTML? Strict or Transitional? If you want the very strictest implementation, opt for a Strict flavor. If you want to give yourself some more leeway, choose Transitional. If you use frames, you must use the Frameset variant. For example, in BBEdit, you can use this menu to choose the (X)HTML flavor you want:
The W3Schools XHTML Reference and the zvon.org comparison page give an overview of the tags you may or may not use in Strict and Transitional. blackwidow.org.uk gives an overview of permitted attributes and a list of common validation errors.
Use XHTML 1.0 Transitional if you have no experience with doctypes. It requires you to use XHTML instead of HTML, and thus forces you to take a step towards standards-compliant markup. On the other hand it allows for more tags and attributes than its Strict brother, so it's easier to implement.
The correct code for using the Transitional DOCTYPE
is shown in the declaration above.
Below you'll find more instructions for writing correct, valid XHTML.