Tutorials
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML Comments

Comment tags are used to insert comments in the HTML source code.



HTML Comment Tags

 

You can also add necessary comments to your HTML source by typing the following syntax:

Example

<!-- Write your comments here -->

you can also notice that there is an exclamation point (!) present in the opening tag, but not present in the closing tag.

Note: Comments will not be displayed by the browser, but they can help you document your HTML source code and have them organised.

With comments you can also keep notifications and reminders in your HTML source:

Example

<!-- This is a comment -->

<p>This is a paragraph.</p>

<!-- Remember to add more information here -->
Try it Yourself

Comments can also be used for debugging HTML, because you can aslo be commenting out HTML lines of code, one at a time, inorder to search for errors:

Example

<!-- Do not display this at the moment
<img border="0" src="pic_mountain.jpg" alt="Mountain">
-->
Try it Yourself

Conditional Comments

 

You might also come across conditional comments in HTML:

Example

<!--[if IE 8]>
    .... some HTML here ....
<![endif]-->

Conditional comments defines some HTML tags to be executed by Internet Explorer only.

Test Yourself with Exercises