The question is purely theoretical.

Often in other scripts I meet the <!-- Sign at the beginning. I will give a piece of code for an example (this is a LiveInternet counter)

 <script> <!-- document.write("<a href='//www.liveinternet.ru/click' ... </script> 

The validator swears at an unclosed sign, but the script is proposed in this form, although without <!-- everything works fine too (like =)

Interested in why it is in the code and how to make it valid?

    3 answers 3

    Here is what they write about this in the textbook :

    Comments before and after scripts

    In very old manuals and books, it is sometimes recommended to use HTML comments inside SCRIPT to hide Javascript from browsers that do not support it.

    It looks like this:

     <script type="text/javascript"><!-- ... //--></script> 

    The browser for which such tricks were intended, a very old Netscape, has long died. Therefore, there is no need for these comments.

    So, to insert a script, we simply write <script> , without additional attributes and comments.

      This is done if suddenly the browser does not support javascript. For example, I went to your site and I have javascript turned off and I show all the code in html, which is not cool. But now it is no longer relevant.

        To hide the script code from older browsers. If the code is not commented out, they can show it as plain text.

         <SCRIPT type="text/javascript"> <!-- to hide script contents from old browsers // end hiding contents from old browsers --> </SCRIPT> 

        The script engine will ignore the first line starting with <!-- . And the end of the HTML comment is hidden from it, putting two slashes at the beginning of the line.