HTML Comments
HTML comments are notes for developers. The browser ignores them — they don't appear on the page, but they are visible in the page source.
Comment syntax
Wrap any text between <!-- and -->:
<!-- and -->.What comments are good for
- Marking sections of a long page:
<!-- Footer starts here -->. - Temporarily hiding markup while debugging.
- Leaving TODOs or context for the next developer.
Note: Anyone can view your source code from the browser. Never put passwords, API keys, or other secrets in HTML comments.
Example
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Comments</title>
</head>
<body>
<h1>HTML Comments</h1>
<p>This is a demo page for the "HTML Comments" lesson.</p>
</body>
</html>
Try it Yourself »
Exercise
Hide this todo note from the rendered page using an HTML comment.
TODO: replace hero image
Comments open with <!-- and close with -->.
Discussion
Loading…