This site heavily relies on bug reports created by its readers. Anyone can report a bug and be published.
Main navigation:
Search reports by browser:
IE applies HTML normalization to the data that is assigned to the innerHTML property. This causes incorrect display of whitespace in elements that ought to preserve formatting, such as <pre> and <textarea>
Test page. Workaround is not included.
Reported by Sebastian Redl.
Explorer 5-6 Windows, Explorer 7 beta 2 | Reported on 22 November 2004.
Posted by Phil Endecott on 26 March 2005
3It also does this when you set a text node's .data property. The only way I've found to change the content of a PRE element and have line breaks in the right place is to use .innerHTML and put tags for newlines. Any other solutiions?
Posted by victor on 7 June 2005
4I've found out that setting outerHTML doesn't trigger normalization. So I've decided to test for .outerHTML property and if not false (i.e., IE), prepend and append the opening and closing pre tags to the content I want to set and assign that to outerHTML.
Posted by Ates Goral on 7 September 2005
5victor: Thanks a lot for the workaround! Saved my day (night actually).
Code excerpt:
// Workaround for IE <PRE> innerHTML normalization quirk
if (elem.tagName == "PRE" && "outerHTML" in elem)
{
elem.outerHTML = "<PRE>" + str + "</PRE>";
}
else
{
elem.innerHTML = str;
}
(Works with IE & FF)
Commenting guidelines:
Posted by Greg Reimer on 24 November 2004
1Applies to list elements also. Specifically, IE removes closing LI tags and insists on adding a line break. Especially troublesome since the line break triggers IE's whitespace-in-CSS-lists bug.