It is part of HTML which is ignored by web browser and is used usually for commenting HTML tag blocks, to indicate sections of a document or any specific instructions about it. It helps to understand the HTML code more easily by adding comments to them. But if comments are used around HTML code then, the code block will not be shown hence, commenting is to be done with care and precaution.
Single Line Comment
It is indicated by special starting tag “<!—“and closing tag “–>” placed at the beginning and end of line to be treated as a comment. Comments do not nest and there should be no space in the start-of-comment string like “< !—“ will not be treated as comment but will be shown on the screen. An example of valid comment is
<!– This is single line comment. –>
Multi line Comments
Commenting multiple lines is done by placing the multiple or different lines between the starting tag “<!—“ and closing tag “–>”to be treated as a comment like
This is multi line comment
and can comment many lines
present in this block.
They are supported by Internet Explorer 5 onwards on Windows, and give instructions specific to Internet Explorer for browser specific instructions. They can also distinguish between different versions 5.0, 5.5 and 6.0 for example
<!–[if IE 6]>
Special instructions for IE 6 here
They are similar to a comment by using “<!– –>”so that other browsers treat them as comment but internet explorer recognize it and executes the instructions.
Some browsers support <comment> tag for commenting.
<comment>This is a comment.</comment>