HTML comments
An HTML comment is a note in the source code that browsers do not render as page content. It starts with <!-- and ends with -->.
What you will learn
- How to write an HTML comment
- When comments help organize or explain source code
- Why passwords and other secrets must not be placed in comments
Basic syntax
<!-- This note is visible in the source, not in the rendered page. -->
Anything between the opening and closing markers is treated as a comment. It does not create a visible paragraph, heading, or other page element.
Useful purposes
- Explain why a section of markup exists.
- Mark the start of a large source-code section.
- Leave a short maintenance note for other developers.
Comments are not private
Visitors can view the HTML source and browser developer tools. Never put passwords, API keys, personal data, or security decisions in a comment. If a block should not be delivered to users, remove it during the build or keep it on the server instead.