Content-type: text/plain

This issue was fixed in Internet Explorer 9.

While we are on the subject of the Content-type HTTP header, XHTML is not the only one that IE gets wrong. It even treats plain text incorrectly. If you send a header that says that you are using plain text, but it contains something that IE thinks is HTML, it will ignore your header, and render it as HTML. So your text file that you carefully prepared gets converted into a run-in paragraph that is almost unreadable, with bits missing and formatting lost.

Why would they do it? Because occasionally, HTML pages are incorrectly served as plain text by web servers. And if that happens, this will make IE render it as HTML. This sounds like a good idea, but what this means is that authors who make these pages do not realise that their page is incorrectly being served as text, because when they check it in IE, it looks like it is working. Browsers that correctly comply with the content type that the page specifies will see the page source instead of its contents. And also, it means that many text files are incorrectly mangled because IE thinks they are HTML.

Either way, someone loses out. But if IE did not ignore the text Content-type header, the author would realise there was a problem, and fix the server instead. The page would work in all browsers, and IE would not screw up text files.

Demo: There is an iframe here containing a text file, not an HTML page.

Workaround: Make sure your server sends the correct Content-type header for web pages, and make sure that any text files do not contain anything that IE might mistake for HTML. If you are using a browser that correctly respects the Content-type header, but you are faced with a page that incorrectly serves HTML as plain text, you can use my 'Force HTML' bookmarklet to convert it back into HTML again. In Opera, you can install my 'fix content type' user JavaScript to automatically apply the fix where it is needed. Unlike IE, this actually tells you when it tries to recover a page (so authors can see they got it wrong), and allows you to go back to the original when it tries to fix pages that do not need to be fixed.

Don't click this link unless you want to be banned from our site.