Sep 052011

Last week I found a bug in Firefox/Chrome while rendering HTML pages. If the script tag is self closed, then the rest of the page is not rendered. The tag needs to be closed with </script> and not />. I spent nearly 2 hours in trying to find why it was not working before finally comparing the page with a working application to find the root cause issue.

What doesnt work:-

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

What works

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

I posted it on my company’s internal microblogging platform and a colleague replied saying that this is not a bug but rather a HTML 4.01 specification to which FF/Chrome are strictly adhering to. Click Here for the page

Though it turned out not to be a bug, I would still appreciate if a more meaningful error message is displayed to the user so it can be corrected. Self closing HTML tags are used quite commonly and it would be great if the browser itself tells you when the closing tag is mandatory