MSIE script tag failure in valid xhtml

An empty script element is not being recognised as legal in MSIE (it is legal by definition in xml/xhtml) so eg ≺script xxxx /≻ fails even though ≺script xxxx ≻≺/script≻ passes.
The workaround is to use a separate close tag.

The bug manifests itself as a blank page - everything after the script open element is considered by the IE parser to be contained by the script declaration.

Test page Workaround is not included
Reported by: Ben Griffin.

Explorer 5-6 Windows, Explorer 7 beta, Explorer Mac | Reported on 8 June 2006.

Atom RSS

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:


(Add your own)

1 Posted by Chris G on 8 June 2006

MSIE doesn't support XHTML. If you send XHTML markup under a text/html content type then browsers will just treat it as plain old HTML and see things like slashes at the end of tags (the shorthand method of closing them in XML) as errors. For elements that don't require closing tags in HTML (such as IMG or BR) the browser's error correction can overcome the syntax, however for things like the script tag it's more of a problem. Browsers like Opera and Firefox are specifically programmed to handle XHTML syntax, even in pages served as HTML just to make sure all these pseudo-xhtml pages that everyone's making these days render as expected, even though the trailing slash is an error, but MSIE does not support XHTML, it merely manages to get past the syntax only on pages sent as text/html by using it's error correction and recovery code. If you send the page using the correct content type then IE will refuse to display it. If you serve it with a generic XML content type then MSIE will attempt to parse the XHTML DTD and fail due to a very old bug that was first reported to MS by the W3C in the IE5.0 days.

So, the bottom line is this isn't a bug. You're simply sending broken syntax in a HTML page and not sending XHTML like you think you are. See:

2 Posted by Tino Zijdel on 21 June 2006

The slash is not the character that is invalid since it is actually defined to be an end-of-tag marker in SGML; this is 100% valid HTML although no browser will render it correctly:

is recognized as a start-tag and the > being the first character of script-data which should yield a syntax error.

But indeed, XHTML syntax sent as text/html is treated as HTML by the browser and since it can be invalid HTML syntax you are relying on the (not defined by spec) error-correction by the browser's renderengine, which is a very bad thing to do.
In my opinion if you sent out an XHTML document as text/html then it is just an HTML document with the wrong DTD.

Bottom line: this is not a bug ;)

Post a comment

Commenting guidelines:

  1. When quoting specs, articles or your own research, please include a URL of the document.
  2. Test your stuff. When reporting browser behaviour, make sure that your report is correct.