A comment is a note in your code that the browser ignores. Visitors do not see it on the page.
<!-- This paragraph explains the opening hours -->
<p>Open daily, 9 to 6.</p>
A comment starts with <!-- and ends with -->. It can cover several lines.
What comments are good for
- Explaining why something is done, not what the tag does.
- Marking sections of a long page.
- Temporarily switching code off while you test.
<p>Visible</p>
<!--
<p>This paragraph is switched off for now.</p>
-->
Comments are not private
Comments are part of the file the visitor downloads. Anyone can read them with View source. Never put passwords, private notes or anything you would not want public inside a comment.
Nested comments
--> ends the comment, so the rest of your code appears on the page. If you comment out a block that already has a comment, remove the inner one first.Keep comments useful
<!-- paragraph --> above a paragraph adds noise. Write comments for decisions, warnings and section labels.