HTML <!-- --> Comments

HTML comments add notes, explanations, reminders, or other information to the source code without displaying the comment text as part of the web page.

Syntax

<!-- Comment text goes here -->

An HTML comment begins with <!-- and ends with -->. The text between these markers is treated as a comment rather than page content.

Example

The following example uses a comment to leave a note in the HTML source code:

<p>This paragraph is displayed in the browser.</p>

<!-- Add another paragraph here later. -->

<p>This paragraph is also displayed.</p>

The comment itself is not displayed as visible content on the web page.

Usage Notes

Comments are useful for documenting sections of HTML, leaving notes for yourself or other developers, and temporarily preventing markup from being displayed while working on a page.

HTML comments cannot be nested. A comment should not contain another complete <!-- --> comment inside it.

Comments are hidden from the rendered page, but they remain part of the HTML source code and can be viewed by visitors. Never place passwords, private information, API keys, or other sensitive information inside an HTML comment.

Browser Support

HTML comments are supported by all modern browsers and have been part of HTML since the early development of the Web.

HTML comments do not require a Baseline compatibility status because they are part of the fundamental HTML syntax rather than a browser feature with varying implementation support.

HTML comments are not elements and therefore do not have directly related HTML elements. They can be used throughout an HTML document to document or temporarily hide portions of the markup.

Specifications

HTML Living Standard: Comments