HTML Comments

Comment is a piece of code which is ignored by any web browser.

HTML comments are placed in between <!-- ... --> tags. So any content placed with-in tags will be treated as comment and will be completely ignored by the browser.

Comments can be used to introduce major sections of the code, or they can be used to explain what a small section of code does. They are also often used at the top of a document to explain things like, author, date first created, purpose of the file, provide info about related files, and more.

<!--This is comment info-->
<p>Comment tags are used to insert comments in the HTML source code.</p>
Try it with the Editor

Multiline Comments

Multiline comments (i.e. comments that span across multiple lines), use the same syntax as single line comments. You begin the comment with <!-- and end with -->. Whether the comment spans one line or ten, you still use the same opening and closing tags.

<!---
<p>Comment tags are used to insert comments in the HTML source code.</p>
<p>Comments can be used to introduce major sections of the code.</p>
--->
Try it with the Editor

Comments are not displayed by the browser, but they can help document your HTML source code.

Conditional Comments

Conditional comments only work in Internet Explorer (IE) on Windows but they are ignored by other browsers. They are supported from Explorer 5 onwards, and you can use them to give conditional instructions to different versions of IE.

<!--[if IE 6]>
    ....instructions for IE 6 here.....
<!--[endif]-->
Try it with the Editor