Are comment tags needed?

Let's investigate whether comment tags are actually needed for modern browsers.

Let's take this code for example:

<title>VBScript/JavaScript combo example</title>
  <script language="vbscript">
  msgbox "VBScript working!"
  <script language="JavaScript">
  alert("JavaScript working!")

OK, we know that this will work in Internet Explorer, so we'll give that a miss, but what does it do in Opera 7? The answer is nothing at all - the script has no effect on the page whatsoever. The same is true in Opera 6. What about Netscape 7? Well, the truth is that the code again has no influence on the rest of the page at all - the code isn't displayed and no errors are generated. The same goes for Netscape 6 and 4 - none need the comment tags!

Finally, Mozilla. Surely Mozilla will need the comment tags! Nope! No needed! Again, the absence of comment tags around the VBScript code has had no effect at all on the browser's ability to display the page.

So, the logical question is, "should we continue to use the comment tags?" Well, surprisingly enough I'm going to say that you should continue to use them.


Because it's better than the alternative. if you currently aren't using them then it's unlikely that you are going to be upsetting many people (except those using really old browsers, of which there are very few indeed). However, if you have got into the habit of using them, unlearning that is going to be equally tricky and you are more likely to introduce coding errors trying to leave them out.

So, if you're using them, carry on using them, if not, then it's good to know that you aren't upsetting many people!

Adrian Kingsley-Hughes
Last updated: July 14th 2004
Print This Page   |   Email me when this page changes    |  Search This Site

Crucial.com System Scanner does the work for you!

/a_global/close_links.inc"); ?>

Contact Us