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
Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.
Subscribe / follow
Sponsors
Authentic Jobs
- Front-End Developer at NEWMEDIA (Denver, Colroado, Co, US)
- User Experience Designer at HMS (Healthcare Management Systems) (Nashville, TN, Te, US)
- Senior Front End Developer at Synacor, Inc. (Buffalo, NY, Ne, US)
- Web Developer
DreamHost web hosting
Use the promo code 456BEREASTREET3 to save USD 20 when you sign up for DreamHost

