The XML conformance tag issue was fixed in Internet Explorer 7 beta 2. The remaining issues were fixed in Internet Explorer 9.

What was that download prompt all about? Or didn't you see it? Try it in IE ;)

Well. There are several versions of HTML. As more and more features were added, the version number increased. It got more and more bloated and the syntax became messier. So Strict HTML was made. This kept the useful features, and removed the features that were not needed, such as where two HTML tags do the same job, or have been replaced by a much better CSS style. Several lazy habits were still allowed, such as omitting closing tags, and using shorthand attribute values. In addition, all HTML browsers had decided to allow the author to make mistakes that were not defined by the specification, and would try to sort through the jumble to convert it into something usable. This made the browsers much more complicated than they should need to be, and it meant that XML features could not be reliably used. So XHTML was made. The messy syntax was no longer allowed, and only the purest, cleanest HTML is allowed. That makes XHTML the most easy of all HTML to interpret.

There is more to it than that, since XHTML understands namespaces, so you can embed content using different XML-based markup languages into the same document (XML, MathML, SVG, RDF, etc.), without risking conflicts. That is one of the most important uses for XHTML. But that is not important right now, since I am not making use of any of that here, this is just plain XHTML.

All I did was tell the browser that I was using XHTML, and that if it wanted, it could use the more efficient XML parser, to save it having to look for mistakes and trying to work out what I meant for it to do. There are no mistakes. Don't believe me? Check this page for pure XHTML syntax. What does IE do? It doesn't actually understand XHTML. Sure, it can look at XHTML pages, it uses the HTML parser, and pretends that the page is full of mistakes. As soon as I tell it that there are no mistakes, it panics, and asks you if you want to download it instead (presumably so that you can then open it in a decent browser).

As a separate but related issue, if you include the XML conformance tag in an XHTML document (yes, you are supposed to include this tag for most encodings), IE 6- will ignore the doctype tag, and will refuse to recognise strict mode. In fact, this incorrect document type detection is the reason that the shadowed page effect does not work, because only in strict mode does IE 6 recognise that HTML and BODY are separate tags that can be styled independently. Try it here to see what I mean (yes, I do know that IE might cut off the floating content when you do that then hover over a link). IE 8 beta 1 fails for completely unrelated reasons.

Another important point about this is that if sent correctly, JavaScript and CSS behave differently. document.write and innerHTML should be replaced by DOM methods, IDs and classes become case sensitive, the body element behaves more like a DIV element, and unless properly escaped, scripts and styles using traditional comments will be ignored. Being unable to treat XHTML correctly, IE does not do this, meaning that we get an inconsistent responce, often with authors blaming the wrong browsers.

Demo: If you didn't see it as the page loaded, click here using IE. It will reload the page with the correct headers.

Workaround: Use a server side detect to send IE the incorrect text/html content type, or send all browsers the incorrect content type (boo!). Using Apache's httpd.conf or .htaccess:
AddType text/html .xhtml
RewriteEngine on
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
RewriteCond %{HTTP_ACCEPT} !application/xhtml\+xml;\s*q=0(\.0)?\s*(,|$)
RewriteRule \.xhtml$ - [T=application/xhtml+xml]

Using PHP:
header( ( stristr( $_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml' ) && !preg_match("/application\/xhtml\+xml;\s*q=0(\.0)?\s*(,|$)/",$_SERVER['HTTP_ACCEPT']) ) ? 'Content-Type: application/xhtml+xml' : 'Content-Type: text/html' );

Don't click this link unless you want to be banned from our site.