Local Time:

HTML Comments


HTML comments are not displayed in the browser. They are used to help you document your source code.


HTML Comment Tag

You can add comments to your HTML source by using the following syntax:

<!-- Your comment goes here -->

You should use comments to explain things to yourself and to future readers. You can use it to leave yourself a reminder to do something or to explain a line or block of code. You might also want to leave comments for another person, for example, you are writing the code for someone else and you need to leave them a note (comment) about things they might need to do or to tell them to leave a section of code alone.

When learning I recommend you use comments often in your code. As you get better at it and things start becoming obvious to you then you can use less comments. When we get into other coding languages you will appreciate the comments you left behind. Especially when it is days, weeks, months or even years that you visited that code.

One final note about HTML comments. You can use them to comment out a line or block of code. For example:

<!-- <h1>Some Heading</h1> -->

<!--
<h1>Some Heading</h1>
<p>Some Text</p>
-->

This is useful for troubleshooting, testing, or maybe you are not sure if you want to keep it or not because everything inside the comment tag will not be displayed in the browser.


Attributes

Working on it