01.04 · Introduction to HTML / Practice · 6 min
Commenting in HTML
Comments help you explain your code, set aside unused content and leave reminders for later.
Activity 4 of 4 in Introduction to HTML
HTML Basics / 01.04
Commenting in HTML
Not started
Use comments to temporarily hide HTML and leave a TODO for future work.
Your lesson progress
Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

ORIGINAL WALKTHROUGH · 5:17
Watch with Rob.
Pause whenever you want to try a change. You can return to the lesson at any time.
You are signed in, but video access needs attention. Check your account access. Your saved work is kept.
Video walkthroughs are included with an active Code Zone membership. The written lesson and practice are free.
Open video & code editor (opens in a new tab)Write a note the browser will not display
An HTML comment begins with <!-- and ends with -->. The browser keeps it in the source without displaying it as page content. Unlike JavaScript, HTML does not use // for comments.
The starter has no comments yet. Try adding <!-- Logo --> above the image as you follow the video. You can also explain why code exists or leave a reminder for future work. Anyone reading the page source can read your comments, so never put passwords or private information in them.
<!-- Navigation links go here. -->
<nav>...</nav>Set aside code without deleting it
Wrap a complete element in a comment to temporarily remove it from the preview. Keep the opening tag, text and closing tag inside the comment. You can restore it later by removing the comment markers.
In our editor, select a paragraph and press Command-/ on Mac or Control-/ on Windows to toggle its comment. On an empty HTML line, the same shortcut creates a comment with the caret ready for your note. Do not put one HTML comment inside another.
<!-- <p>Registration is closed.</p> -->
<p>New dates will be announced soon.</p>Leave a TODO for your next change
Start a reminder with TODO: so it is easy to find when you return. A TODO is a note for a developer, not an instruction the browser executes.
In Your turn below, hide an expired promotion while keeping its source code. Then add a TODO immediately below the h1, before the next visible paragraph. The video workspace is ungraded so you can experiment freely.
<h1>Our next workshop</h1>
<!-- TODO: Add the workshop date. -->
<p>Details are coming soon.</p>YOUR TURN
Hide an old promotion and leave a reminder
Open index.html and follow the checklist. Run the preview, then choose Check challenge. Keep the supplied content unless an item asks you to change it.
- Inside the
mainelement, find the complete paragraph containingOur old promotion has ended. - Surround that entire paragraph, including its tags, with an HTML comment. Preserve it in the source rather than deleting it.
- Immediately after the closing tag of the h1 containing
Community updates, add another HTML comment. - Make the reminder comment contain
TODO: Add the next workshop date. - Keep the h1 and the paragraph
Check back soon for our next workshop.visible. Neither the old promotion nor the TODO should appear in the preview.
Edit HTML, then run it to see the page. Check Challenge checks the rendered elements. Word wrap is enabled.
Ready to checkRun the checks to see your results here.
Your check results
Need a nudge?
Hide the whole paragraph
Put <!-- before the paragraph’s opening <p> and --> after its closing </p>. Keep the paragraph’s text inside the comment.
Add a reminder below the heading
On the line after </h1>, type <!-- TODO: Add the next workshop date. -->. Do not put the reminder inside the h1 or inside the comment around the old promotion.
One possible solution
Your code may look different and still be correct. Compare the approach with your own.
The old paragraph is still in the source, ready to restore later. Your TODO records the next task without appearing on the page. The heading and current paragraph stay visible.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Community updates</title>
</head>
<body>
<main>
<h1>Community updates</h1>
<!-- TODO: Add the next workshop date. -->
<!-- <p>Our old promotion has ended.</p> -->
<p>Check back soon for our next workshop.</p>
</main>
</body>
</html>Ready to try it?
Practice in your browser and see your results.
Progress details
Have a question?
Ask the Code Zone community.
Ask a question in The Code Zone (opens in a new tab)