The HTML Doctype: Hello! HTML5 and CSS3
The HTML Doctype: Hello! HTML5 and CSS3
The HTML Doctype: Hello! HTML5 and CSS3
An article from
Rob Crowther
MEAP Release: September 2010
Softbound print: Spring 2011 | 325 pages
ISBN: 9781935182894
This article is taken from the book Hello! HTML5 and CSS3. The author discusses doctype,
which HTML5 doesn’t need for validation but still needs to be triggered for legacy browsers to
render pages in standards-compliant mode.
Get 35% off any version of Hello! HTML5 and CSS3 with the checkout code
fcc35. Offer is only valid through www.manning.com.
The DOCTYPE declaration is somewhat archaic; it comes from SGML, which was used to define previous versions of
HTML in terms of the language syntax. It appears as the first thing in an HTML document and serves two practical
functions:
! It is used by HTML validation services to determine which version the document uses
! When browsers use the DOCTYPE to determine whether to use standards, almost standards, or quirks mode
to render the document. (The short version is: standards mode is what you want.)
HTML5 is defined in terms of its DOM representation after parsing, so it doesn’t need a DOCTYPE for validation, but
we still want legacy browsers to render pages in standards-compliant mode. With this in mind the authors of the
HTML5 spec worked out the minimal amount of markup required to trigger standards mode in browsers:
<!DOCTYPE HTML>
Compare this with similar declarations for HTML4 and XHTML1:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
For Source Code, Sample Chapters, the Author Forum and other resources, go to
http://www.manning.com/crowther/
Summary
In this article, you’ve learned that HTML5 doctype is much shorter, easier to type, and easier to remember.
For Source Code, Sample Chapters, the Author Forum and other resources, go to
http://www.manning.com/crowther/
Here are some other Manning titles you might be interested in:
Vernon L. Ceder
January 2010 | 360 pages
ISBN: 9781935182207
IronPython in Action
IN PRINT
Hello World!
IN PRINT
For Source Code, Sample Chapters, the Author Forum and other resources, go to
http://www.manning.com/crowther/