Search code examples
htmltagsinternet-explorer-10

Blank lines are removed in the HTML <pre> tags in IE10


Empty lines inside the tag are displayed ok in the latest Chrome and Opera browsers, but in IE 10 they are removed. Is it a known issue, or is there a CSS or another setting to display the tag contents "as is" properly in all browsers including IE?


Solution

  • This is a strange bug in IE 10. Observations on it:

    1. Appears when a line consists of space characters only (not for a completely empty line; the page mentioned has lines consisting of one space only).
    2. Appears when the doctype declaration is for XHTML 1.0 Transitional (but not with <!doctype html> and not without any doctype).
    3. Appears both in standards mode and in quirks mode.
    4. Keeps appearing when browser is set to emulate (via “Document mode” in F12 settings) IE 9 or IE 8, but not when set to emulate IE 7 or IE 5.
    5. Also appears for a div element when white-space: pre is set on it.

    Speculation: When IE 10 tries to deal with XHTML, it gets confused with white space processing somehow.

    Workaround: Replace the lines with spaces only by completely empty lines.