Issues with "Self-Closing" Tags

by Dave MichelFebruary 25, 2013

I was bit by this again a couple of weeks ago when I went on autopilot and did something like this:

<script type="text/javascript" src="/Scripts/Header/01-jquery.js" />
<script type="text/javascript" src="/Scripts/Header/blog.js" />
<script type="text/javascript" src="/Scripts/Header/jquery.colorbox-min.js" />
<script type="text/javascript" src="/Scripts/02-jquery.cookie.js" />
<script type="text/javascript" src="/Scripts/04-jquery-jtemplates.js"" />

The 01-jquery.js file loaded fine, but all the scripts below it were ignored. After fighting with this for a while, I remembered that HTML and XML are parsed differently, Everything worked great after I explicitly put in closing tags like this:

<script type="text/javascript" src="/Scripts/Header/01-jquery.js"></script>
<script type="text/javascript" src="/Scripts/Header/blog.js"></script>
<script type="text/javascript" src="/Scripts/Header/jquery.colorbox-min.js"></script>
<script type="text/javascript" src="/Scripts/02-jquery.cookie.js"></script>
<script type="text/javascript" src="/Scripts/04-jquery-jtemplates.js"></script>

When writing HTML, bear in mind that the nice XML shortcuts we take for granted may not parse properly under certain circumstances. HTML != XML, and HTML != XHTML, as far as a browser's parser goes. There's some good info concerning this at

About the author


Dave is a recording engineer, musician and software developer in Minneapolis.

Month List