Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Voices That Matter

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

2. Missing DOCTYPE Declarations

The lack of DOCTYPE declarations in HTML and XHTML documents is very likely the most deadly of deadly markup sins. First, it's important to understand that a DOCTYPE declaration is a required component of your HTML or XHTML document. Without it, you won't validate, and that's that.

DOCTYPE declarations are a bit of SGML placed at the top of a document to declare which language and language version the document is supposed to conform to. In the past, the declaration was passive—ignored by the browser until you'd validate the document, in which case the validator would use the DOCTYPE declaration to compare your document with the declared Document Type Definition (DTD). I like to describe DTDs as laundry lists of allowed elements and attributes for a given language and language version. In order to have a conforming document, authors must use only the allowed elements and attributes in the DTD declared.

But a technology known as DOCTYPE switching has made using the correct DOCTYPE declaration not only important, but imperative. DOCTYPE switching is a technology in many contemporary browsers such as IE 6.0 that will flip a switch within the browser upon finding a correct DOCTYPE in the document, allowing it to operate in standards mode. In the case of IE 6.0, which has a non-standard implementation of the Box Model (a very important browser concern when working with CSS), the DOCTYPE switch allows IE 6.0 to operate with a standards-compliant Box Model.

The simple advice here is to understand how important DOCTYPE declarations are, what makes up a correct declaration, and (most importantly) to include the correct DOCTYPE declaration for your document needs in every document. No exceptions, ever.


To better understand the role of DOCTYPEs and DOCTYPE switching, please see my InformIT article "CSS: Beyond the Retrofit."

  • + Share This
  • 🔖 Save To Your Account