HTML Comments

Notes in your code that the browser ignores.

✍️ 3 exercises + code challenge in this lesson

Comments let you leave notes in your HTML. They are not displayed in the browser.

A comment starts with <!-- and ends with -->.

Uses for comments

  • Explain tricky parts of your code.
  • Temporarily hide content while testing.
  • Mark the start and end of large sections.
Comments are still visible in the page source, so never put passwords or private notes in them.

Key Takeaways: HTML Comments

Mastering HTML Comments helps you write clean and reliable HTML code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

HTML Comments Code Example

HTML
<!-- This is a comment -->
<p>This paragraph is visible.</p>

<!--
<p>This paragraph is hidden by a comment.</p>
-->

<p>So is this one <!-- except for this hidden part -->.</p>
Free sign-in required · Google login available

HTML Comments Practice Exercises

Check what you learned in “HTML Comments”.

/ 3 solved
Fill in the blank

Complete the HTML comment.

 This is a comment 
✓ Correct! Not quite. Try again.
Multiple choice

Are HTML comments shown in the browser?

✓ Correct! Not quite. Try again.
Code challenge

Hide the second paragraph by turning it into a comment.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services