xhtml Script Tag in Internet Explorer

This one caused me a headache for a bit, trying to figure out what was wrong. Don’t use something like this in internet explorer…

<script type="text/javascript" src="script.js" />

For some reason, ie doesn’t understand the xhtml tag properly, and up goes your page in a puff of smoke – the source looks fine, and validates, but explorer renders a blank page. For xhtml compliance, just use:

<script type="text/javascript" src="script.js"></script>

…and it works fine.

3 Responses to “xhtml Script Tag in Internet Explorer”

  1. Gravatar Image

    Thanks! Life saver!
    http://twiggyframe.marquettecollective.com

  2. Gravatar Image

    One more thing to remember with this is that if you are using XSLT to generate your XHTML, then the XSLT processor is likely to change from

    to

    you can fix this with the following

    // IE BUG FIX

    – Hopefully this will save someone some time :)

  3. Gravatar Image

    well, the code that I tried to show in my comment has been stripped out…. so I’ll try again

    If you are generating your XHTML from the result of an XSL transformation, then the XSLT processor is likely to take your working script tags, and optimise them to the non working script tags.

    This problem can be avoided by place a JavaScript comment in between the opening script tag and the closing one. For my comment I’m just using // IE BUG FIX.

    – Hope that makes sense, and helps someone :)

Leave a Response



XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



  • Search
  • Meta

  • Old Browser

    It seems you are using an old web browser (e.g. Internet Explorer 5 or below). This is a security risk to you, since Microsoft no longer releases updates for old versions of Internet Explorer. Also, note that this site is designed to modern internet standards, and the layout may appear strange or plain in older browsers. All the content is still accessible to you, but I strongly recommend you upgrade to a modern, safe, standards-complient browser, such as Firefox. For more information on getting the best experience surfing the web, see browsehappy.com.