Jump to content

Html Comment Tag Confusion


gameboyz

Recommended Posts

Hi pls don't misunderstand as a html question. I'm reading the javascript tutorial when I came across this: in order to make the script "browser friendly" for older browsers, it's good practice to include the "<!--" and "//-->" right? I also read that the "//" is a javascript comment tag which is to prevent execution of the "-->" ..Then why isn't the "<!--" after the "//" too? And is it okay not to enter the "//" as it works fine (I experimented).

Link to comment
Share on other sites

If you put // before <!-- it would appear as text in the browsers that display scripts, but anyways, I don't see a need to comment script. The only browsers that display script are very old. I don't think there's anybody who uses them anymore.

Link to comment
Share on other sites

If you put // before <!-- it would appear as text in the browsers that display scripts, but anyways, I don't see a need to comment script. The only browsers that display script are very old. I don't think there's anybody who uses them anymore.
Okay, but for browsers which are very old which can't support javascript, why is there a need for // before the -->? Since javascript is not supported, the --> won't be executed right?
Link to comment
Share on other sites

Okay, but for browsers which are very old which can't support javascript, why is there a need for // before the -->? Since javascript is not supported, the --> won't be executed right?
Only the comment tags are for the older browsers. The // is for almost-modern browsers that DO read the javascript. Without the slashes, the script would try to execute the closing comment. Truly modern browsers seem to understand the closing comment tag without the slashes.But I'm with Ingolme. I don't mess with the comment tags anymore. No problems.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...