HTML Comment


Comments are piece of code which is ignored by any web browser.

It is good practice to comment your code, especially in complex documents, to indicate sections of a document, and any other notes to anyone looking at the code.

Comments help you and others understand your code.

HTML Comment lines are indicated by the special beginning tagĀ <!-- and ending tag -->placed at the beginning and end of EVERY line to be treated as a comment.

Note:There is an exclamation point (!) in the opening tag, but not in the closing tag.

Comment Syntax:
<!-- Write your comments here -->

Multiline Comments

 <!--
                  Write your comments here
                  Write your comments here
                   -->

Conditional Comments

Conditional comments only work in Explorer on Windows, and are thus excellently suited to give special instructions meant only for Explorer on Windows.

They are supported from Explorer 5 onwards, and it is even possible to distinguish between 5.0, 5.5 and 6.0.

<--[if IE 6]>
   Write your comments here
   Write your comments here
<![endif]-->

Using Comment tag

   <p> Learn More <comment> and </comment> Enjoy More </p>

Commenting Scripts

<script>
<!--
   document.write("Hello World!")
 //-->
</script>

Share this article on