Curriculum ▸ HTML Zero → Mastery ▸ Lesson 16: HTML Comments (<!-- -->) Foundations

Lesson 16 — HTML Comments <!-- -->

Learning Goals

Part 1 — What are Comments?

HTML comments let you leave notes in your code that browsers ignore. They are useful for explaining code, marking sections, or temporarily disabling elements.

They will not appear on the webpage, but anyone can see them by viewing the source code.

Part 2 — Example

<!-- This is a comment -->

<p>Visible paragraph.</p>

<!-- <p>This paragraph won’t display</p> -->

Result: The first comment and the second commented-out paragraph are ignored by the browser.

Part 3 — Best Practices

Part 4 — Common Mistakes

Quick Quiz

  1. What is the syntax for an HTML comment?
  2. Do comments show up on the webpage?
  3. Why should you avoid putting passwords in comments?
Sample Answers
  • <!-- comment text -->
  • No, they are ignored by browsers.
  • Because anyone can see them in the source code.

Mini Project — Code Annotation

Create a small HTML page with a header, paragraph, and footer. Add comments above each section describing what it does. Then try “commenting out” one element to hide it.

Lesson 16 Dictionary

<!-- --> (Comment)
Used to add notes in code that browsers ignore.