since IE won't render XHTML as XHTML, but treat it as HTML instead, when can this actually cause problems for IE?
i know of one case, where
<div style="clear:both" />
in browsers that support XHTML, the div is closed. But IE will treat the div as still open, so the layout can have unexpected result later.
Internet Explorer will have trouble distinguishing XHTML documents from XML documents if the MIME-type is not specified as text/html. However, because it fully supports HTML 4.01 the majority of problems arise from inconsistent and non-standards implementations of positioning, layout, and CSS properties. To avoid any problems it is best to write valid XHTML and specify a DOCTYPE.
These all apply to any browser treating XHTML as text/html rather than specifically IE, but you should read Appendix C of the XHTML 1.0 spec here: http://www.w3.org/TR/xhtml1/#guidelines
Self-closing syntax won't work (it will appear to work only on elements that are always empty in HTML). XML serializers might generate
<textarea/>
,<script/>
and similar, which break pages in various ways (triggering complicated error recovery, sometimes involving re-parsing of remainder of the page).Explicitly closed HTML "empty" elements might behave oddly (
</br>
inserts break in IE).<![CDATA[
outside HTML's hardcodedCDATA
elements will be recognized as a tag. It won't affect escaping and might make some content disappear.In HTML's
CDATA
elements (namely<script>
) entities won't be recognized. XHTML requires<script> if (1 < 2) …
which is going to be syntax error in IE.Background of
<body>
will be applied differently in IE.There will be no cross-browser syntax for namespace-aware selectors in CSS.
You'll get all implied HTML elements (e.g.
<tbody>
in all tables) and implictly closed elements (it's usually not a problem when document is valid, but other browsers won't warn you as long as markup is well-formed).Elements and attributes with prefixes won't be namespaced and will get different
tagName
in IE (which is also illegal in XML). They won't get appropriate default styling and behaviour either (<xhtml:a>
can't be a link).You won't be able to use namespace-aware methods like
createElementNS
(they don't exist in IE),.tagName
will be uppercase in IE, but not in all cases.Elements and attributes with prefixes won't be namespaced and will get different local name in IE (which is also illegal in XML).
These are only problems concerning switching from working XML document to HTML. There are as many surprises when you're going from HTML (i.e. what everyone expects and takes as normal behavior) to real XML, e.g. document.write
doesn't work rendering most of Google's scripts useless.