Comment tags are used to insert comments in the HTML source code.
Comment is a piece of code which is ignored by any web browser. It is a good practice to add comments into your HTML 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 and increases code readability.
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.
You can add comments to your HTML source by using the following syntax:
See this example:
Output:
<!-- Write your comments here -->
Notice that there is an exclamation point (!) in the opening tag, but not in the closing tag.
Note: Comments are not displayed by the browser, but they can help document your HTML source code.
With comments you can place notifications and reminders in your HTML:
See this example:
Output:
Comments are also great for debugging HTML, because you can comment out HTML lines of code, one at a time, to search for errors:
See this example:
Output:
You might stumble upon conditional comments in HTML:
See this example:
Output:
Conditional comments defines some HTML tags to be executed by Internet Explorer only.