HTML comments start with **`<!--`** and end with **`-->`**. The browser's parser reads them but does not display them or run any code inside them — they exist purely for developers reading the source. Unlike JavaScript comments, HTML comments can span multiple lines without special syntax, and they are still visible to anyone who views the page source, so they are not a way to hide sensitive information.
1Understanding HTML Comments
HTML comments start with `<!--` and end with `-->`. The browser's parser reads them but does not display them or run any code inside them — they exist purely for developers reading the source. Unlike JavaScript comments, HTML comments can span multiple lines without special syntax, and they are still visible to anyone who views the page source, so they are not a way to hide sensitive information.
Comments in HTML are visible to any visitor who opens 'View Page Source' — never leave API keys, internal notes, or credentials inside them.
<!-- Header section -->
<header>
<h1>My Site</h1>
</header>
<!-- End header -->
<!-- TODO: add the pricing table here -->2Practical Example
Here is a real-world application of HTML Comments showing how it is used in production HTML.
<!--
Conditional comments (IE-only, deprecated):
modern browsers ignore these entirely.
-->
<p>Visible paragraph</p>3Best Practices
Follow these guidelines when working with HTML Comments:
1. Use comments to mark the start/end of large sections, e.g. <!-- Navbar -->
2. Remove leftover commented-out code before shipping to production
3. Never put secrets or sensitive notes inside HTML comments
Tip: Comments in HTML are visible to any visitor who opens 'View Page Source' — never leave API keys, internal notes, or credentials inside them.
<!-- Header section -->
<header>
<h1>My Site</h1>
</header>
<!-- End header -->
<!-- TODO: add the pricing table here -->