HTML Comments: Syntax, Uses and Safety
Learn how to write HTML comments, when comments help maintain code, and why they cannot keep private information secret.
Write an HTML comment
An HTML comment starts with <!-- and ends with -->. Browsers do not display its text as page content.
<!-- Navigation links for the site header -->
When to use comments
Comments can label a complex section or explain a non-obvious decision for someone maintaining the source. Keep them brief and remove notes that are no longer accurate.
Comments are not private
Comment text remains in the HTML source sent to the browser. Visitors can inspect it, so never put passwords, API keys, personal data or confidential notes in a comment. HTML comments also cannot be nested reliably.