LESSON 13
HTML Comments
Learning objective: Leave notes in your code that the browser ignores.
Understand
Comments help you and others understand your HTML.
An HTML comment is written between <!-- and -->. The browser ignores it, so it is perfect for notes, reminders, or temporarily disabling a chunk of markup while you experiment.
Analogy: A comment is like a sticky note in the margin: helpful to read, but not part of the final page.
See It in Action
A comment and some code:
<!-- Main navigation goes here -->
<nav>...</nav>
<!-- <p>Hidden for now</p> -->How it works: The first comment is a note; the second wraps a paragraph so it is temporarily disabled without being deleted.
Try It Yourself
- Add a comment above a section explaining what it does.
- Comment out one element and refresh to see it disappear.
- Un-comment it to bring it back.
Quick Quiz
How does the browser treat an HTML comment?
Challenge
Add helpful comments to label the main parts of one of your pages.
Success condition: Your page has clear comments and none of them appear on screen.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →