Dan Michael Heggå wrote:
RobG said:
<snip>
>Do not use XML-style tag closures ( />) for HTML. IE does not have
any understanding of XML, use HTML 4.01 Strict.
Really? It's a little late to change the doctype of the site, since
it's three years old and has grown quite big. Is this a problem only
when using innerHtml or in common? I haven't noticed any problems with
the /so far.
Using - innerHTML - highlights the issue. You have not had a problem
because you server your XHTML-like mark-up with a content-type header
of text/html, which effetely asserts that the document is an HTML
document. So the browsers interpret your document as HTML, tag soup
HTML with lots of errors (the aspects of the mark-up that would make it
XML in other contexts), and error-correct your mark-up back to HTML
that they are capable of handling.
This means that when you come to script the document the browser is
providing an HTML DOM to be scripted rather than an XHTML DOM. And
because the browser is providing an HTML DOM you can use features such
as - innerHTML - because they work there but often don't work in XHTML
DOMs.
However, if a DOM is scripted as an HTML DOM, and because most
non-trivial HTML DOM scripts will not work at all in an XHTML DOM, it
becomes important that the document in question is only ever
interpreted as HTML. And if the scripting of a document is absolutely
dependent upon its mark-up being interpreted only as HTML it is not
rational for that mark-up to resemble the XHTML that it must never be
interpreted as by a web browser. It is generally difficult to persuade
programmers that doing something that is irrational is a good idea.
Richard.