The Doctype
From the top:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
This is called the doctype. Thereâs a long historyâand a black artâbehind the doctype. During the development of Internet Explorer 5 for Mac, Microsoft found itself with a surprising problem. The upcoming version of its browser had improved its standards support so much, older pages no longer rendered properly. Or rather, they rendered properly (according to specifications), but people expected them to render improperly. The pages themselves had been authored based on the quirks of the dominant browsers of the day, primarily Netscape 4 and Internet Explorer 4. IE5/Mac was so advanced, it actually broke the Web.
Microsoft came up with a novel solution. Before rendering a page,
IE5/Mac looked at the âdoctype,â which is typically the first line of the
HTML source (even before the <html>
element). Older pages (that relied
on the rendering quirks of older browsers) generally didnât have a doctype
at all. IE5/Mac rendered these pages like older browsers did. In order to
âactivateâ the new standards support, web page authors had to opt in by
supplying the right doctype before the <html>
element.
This idea spread like wildfire, and soon all major browsers had two modes: âquirks modeâ and âstandards mode.â Of course, this being the Web, things quickly got out of hand. When Mozilla tried to ship Version 1.1 of its browser, it discovered ...
Get HTML5: Up and Running 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.