Home > Internet, Programming > Formatting <script /> elements

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?

Advertisements
Categories: Internet, Programming Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: