iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

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 -->:

<!-- This is a comment --> opens closes
Fig 1. A comment delimited by <!-- 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

Test yourself

Q1. HTML comment syntax is…
Q2. Comments in HTML are…
Q3. Use comments to…

Discussion

Loading…