Archive for August 28th, 2007|Daily archive page
Formatting <script /> elements
When I first started using JavaScript in my Web pages, I would always add the tag like this:
<script type="text/javascript" src="somefile.js"></script>
After doing more and more research to improve my skills, I came across an article that said (if I recall this correctly) there was a bug in some browser with the <script> element and to correct it, you should format your <script> elements like this:
<script type="text/javascript" src="somefile.js"> </script>
The space between the opening and closing tags of the element is the only difference between the two code examples. I do not remember if this is necessary or not, but I have been adding my <script> elements like the latter example for years now, and to this day, in fact.
Does anyone know which way is correct? Does it matter? Was there ever a need to put a space between the opening and closing tags?
Leave a Comment