HTML and CSS Reference
In-Depth Information
code, and “best viewed in . . .” graphics. Only a few developers were writ-
ing valid code, reading specifications, and using DOCTYPES like those
designating XHTML. This provided an opportunity to use the DOCTYPE
declaration (or lack thereof) to indicate the type of code being written
and therefore to switch between modes.
A missing or invalid DOCTYPE will put a browser into Quirks Mode, as will
the following:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 3.2 Final//EN”>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01
Transitional//EN”>
The following will put browsers into Standards Mode or Almost
Standards Mode:
<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0
Transitional//EN”>
The Wikipedia article on Quirks Mode ( http://en.wikipedia.org/wiki/
Quirks_mode ) contains a more complete chart of behaviors.
X-UA-Compatible
Having just two modes is not enough for some, particularly those build-
ing closed or internal applications using web technologies. Microsoft has
shown concern that changes or fixes to the browser will break already
tested and deployed code in ways that DOCTYPE switching alone could
not satisfy. The X-UA-Compatible header, when set via an HTTP header or
<meta> tag, was introduced as a way to lock IE8 and beyond into behav-
ing like a specific older version of the browser. The following example
tells the browser that it should behave like IE8 in Standards Mode:
 
 
Search WWH ::




Custom Search