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.