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 Single line comment:
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.
Comments do not nest, and the double-dash sequence “–” may not appear inside a comment except as part of the closing –> tag. You must also make sure that there are no spaces in the start-of-comment string.
For example: Given line is a valid comment in HTML:
<html> <head> <title>HTML comment demo</title> </head> <body> <!-- This is commented out --> <font color="red">Old lorem text</font> <font color="Blue">new lorem text</font> </body> </html>
HTML Multiline Comments:
Be careful if you use comments to “comment out” HTML that would otherwise be shown to the user, since some older browsers will still pay attention to angle brackets inside the comment and close the comment prematurely — so that some of the text that was supposed to be inside the comment mistakenly appears as part of the document.
You have seen how to comment a single line in HTML. You can comment multiple lines by the special beginning tag <!– and ending tag –> placed before the first line and end of the lastline to be treated as a comment.
For example:
<html> <head> <title>HTML Multiline comment demo</title> </head> <body> <!--Â Â This is a multiline comment <br /> and can span through as many as lines you like. --> </body> </html>
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.
Conditional comments work as follows:
<html> <head> <title>HTML Multiline comment demo</title> </head> <body> <!--[if IE 6]> Special instructions for IE 6 here <![endif]--> </body> </html>