Yes. When you use innerHTML
, the browser recreates the HTML based on the DOM elements and attributes in the element. Different browsers do so differently, because until recently there was no standard (innerHTML
was a Microsoft innovation which was adopted by nearly everyone else, and is being standardized in HTML5). If your markup looks like this:
<span style="color: red" id="foo">...</span>
IE's innerHTML
for that will be:
<SPAN id=foo style="COLOR: red">...</SPAN>
...whereas Firefox and Chrome are pretty close to your original.
What IE gives you is valid HTML (you're allowed to omit the quotes on attributes that don't have spaces in them, and UPPER CASE tagnames are okay too), but not valid XHTML (if that's important for what you're doing).
You can build your own (X)HTML string if you like by traversing the DOM tree yourself, or post-process IE's result.
The good news is that now that innerHTML
is being standardized, and the standard clearly says that the result should be valid XML in an XML document (which XHTML documents are), and since Microsoft is more engaged and dedicated to standards in this area than they've been in years, it's likely that IE9 will do better in this regard.