Hiding JavaScript from older browser

Because not all browsers support JavaScript, we need a way to hide JavaScript from those browsers. If we do not JavaScript from those browsers, those browsers will treat JavaScript as page's content and thus display that code on the web page. To avoid that problem, we can use the comment tags to hide the <script> tag. The following:

<script language="JavaScript">
JavaScript commands

instructs browsers to ignore JavaScript if they don't recognize JavaScript. How? Suppose we have an old browser that does not understand JavaScript. When this browser sees the above code, it ignores the first <script> tag, as it ignores any other tag that it does not recognize. The second line (<!--) starts an HTML comment. Text inside the comments is ignored by browsers and thus is not displayed on the webpage. To end a comment, we use -->. Thus any JavaScript code (line 3 above) placed inside the HTML document is ignored.

A browser that supports JavaScript will be able to execute the above code because it will ignore the HTML comments inside the <script> tag.