HTML Comments
Comments leave notes for people reading a document’s source. They do not appear as normal page text, but they are still delivered to the visitor’s browser.
How it works
- Start a comment with <!-- and close it with -->. Comments can cover multiple source lines.
- Use comments to explain a decision or identify a section, rather than repeating what an obvious element already says.
- Removing markup from display is not the same as protecting information. Page source and developer tools can reveal comments.
A practical example
<!-- Keep opening times together so they can be updated in one place. -->
<section>
<h2>Opening times</h2>
<p>Saturday, 10:00–13:00</p>
</section>
Visitors see the heading and opening time. A developer inspecting the source can also read the maintenance note.