SYSK 147: On the Importance of Script Closing Tags

Are the following two lines semantically different?

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

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


As it turns out (at least in IE 6.0) they are… 


The first line with the explicit closing script element, the code works as expected.  However, IE stops processing the document at the <script … /> line, which means that if your html rendering code is below that line, you’ll get a blank page displayed; and if you have the html UI before the script line, you’ll get 'Object expected' error…


Try it for yourself:

<head runat="server">

    <title>Test Page</title>      

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



    <form id="form1" runat="server">


            <input id="Text1" type="text" />

            <input id="Button2" type="button" onclick="DisplayText();" value="Press Me" />






// JScript File

function DisplayText()





**  Firefox doesn’t seem to “suffer” from this problem.


Comments (1)

  1. hasanib says:

    does ie7 have this "feature" too?


Skip to main content