Rendering Modes, Flavors of HTML, and Document Type Declarations

As of this writing, HTML has been steadily evolving for 17 years. Five versions have been developed, and HTML5, the most recent of these, is steadily making its way to popular use though it is not yet complete. The World Wide Web Consortium (W3C) has also published a Recommendation for XHTML, the XML-conformant version of HTML 4.01.

Note

While it is still too early to know what the “good parts” of HTML5 will be, throughout this book we will cover new HTML5 functionality where it might change best practices.

Since version 1.0, HTML has included something called the document type declaration at the very beginning of the document. This identifies the version of HTML used in a document to a user agent, but was generally ignored by web browsers until 2001. For example, the document type declaration for HTML 4.01 Strict would look like the following:

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

The most significant impact of the document type declaration is its influence on the way that element footprints are rendered. Different DOCTYPEs lead to different rendering modes. (They also set expectations for HTML validators.)

Note

You’ve probably seen the acronym “DTD,” which expands to “Document Type Definition.” The DTD is the machine-readable definition that the document type declaration is intended to reference. At any rate, the declaration and definition are different matters; the former ...

Get HTML & CSS: The Good Parts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.