HTML and CSS Reference
The important element in each of these versions is the URL, which points to the Document Type Definition
(DTD). Browsers use this reference to the DTD to render CSS in standards mode —in other words, according to
the CSS specification. Some older HTML editing programs omit the URL like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
If you use a shorter version of the HTML 4.01 or XHTML 1.0 DOCTYPE or omit the DOCTYPE altogether,
browsers switch to quirks mode , which results in widths being applied incorrectly.
■ Quirks mode is hangover from the days when internet Explorer interpreted the Css box model (see
Chapter 6 ) incorrectly. iE 6 corrected the problem, but browsers used the DOCTYPE to switch between quirks and
standards mode to prevent breaking the huge number of web pages that had been designed using the wrong
interpretation of the standard.
he HTML5 DOCTYPE is now the recommended version, which you can safely use in all browsers—even IE 6.
It was designed as the shortest string of characters guaranteed to switch all browsers into standards mode.
Deciding Which Selector to Use
The CSS2.1 specification defines 22 selectors, and CSS3 adds almost as many again. Instead of attempting to
cover the full range, I think it makes sense to begin with a subset of the most widely supported. The last four items
in Table 2-1 (attribute selectors) are not supported by IE 6, but I've included them in this list because they are so
useful and because IE 6 now has an insignificant market share in most parts of the world.
The first column in Table 2-1 follows the convention in the CSS specification of using E and F to represent
generic selectors. The meaning should become clear in the descriptions and exercises that follow in the rest of