Skip to content

HTML Tutorial Text Content

HTML Comments: Notes in Your Code That Visitors Do Not See

Lesson 15 of 81 2 min read By Deepak Paswan Updated Oct 4, 2026

A comment is a note in your code that the browser ignores. Visitors do not see it on the page.

index.html
HTML
<!-- This paragraph explains the opening hours -->
<p>Open daily, 9 to 6.</p>

A comment starts with <!-- and ends with -->. It can cover several lines.

What comments are good for

  • Explaining why something is done, not what the tag does.
  • Marking sections of a long page.
  • Temporarily switching code off while you test.
index.html
HTML
<p>Visible</p>
<!--
<p>This paragraph is switched off for now.</p>
-->

Comments are not private

Comments are part of the file the visitor downloads. Anyone can read them with View source. Never put passwords, private notes or anything you would not want public inside a comment.

warning
Nested comments
You cannot put one comment inside another. The first --> ends the comment, so the rest of your code appears on the page. If you comment out a block that already has a comment, remove the inner one first.
lightbulb
Keep comments useful
A comment like <!-- paragraph --> above a paragraph adds noise. Write comments for decisions, warnings and section labels.