Using an XML declaration triggers Quirks mode in IE 6
If you use an XHTML doctype in your documents, do not include an XML declaration unless you want Internet Explorer 6 to use its Quirks mode. An XHTML 1.0 Strict doctype with an XML declaration looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
IE 7 and later are not affected and will use Standards mode. Neither are other browsers (except for old versions of Opera).
The most obvious effect of IE 6 using Quirks mode is probably that it will use a broken CSS box model. More info on that can be found in Internet Explorer and the CSS box model.
The XML declaration is optional if you use UTF-8 or UTF-16, so my recommendation is to simply remove it and use the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
This post is a Quick Tip. Background info is available in Quick Tips for web developers and web designers.
- Previous post: Let your links look like links
- Next post: Use the fieldset and legend elements to group HTML form controls