Coding Now – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 9667708830
Back to HTML Notes
Topic #107

HTML Comments

HTML comments are ignored by the browser — useful for leaving notes in your markup or temporarily disabling a block of code.

Syntax

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

Multi-Line Comments

<!--
  TODO: replace this placeholder testimonial section
  once the real client quotes are approved by marketing.
-->

Commenting Out a Block Temporarily

<!--
<section class="promo-banner">
    <p>Limited time offer!</p>
</section>
-->

Useful while debugging a layout issue — hide a section without deleting the code, then remove the comment markers once you've confirmed the fix.

Important: Comments Are Not Hidden From Users

HTML comments are stripped by nothing — anyone can view them via "View Page Source." Never put sensitive information in an HTML comment (API keys, internal notes about security issues, unpublished content).

Common Mistakes

  • Nesting comments — <!-- outer <!-- inner --> still outer --> does not work as expected; the comment ends at the first -->
  • Leaving large blocks of commented-out dead code in production files instead of removing it via version control
  • Writing sensitive or embarrassing internal notes in comments, forgetting they're publicly visible in page source

Interview Relevance

Rarely tested directly, but "are HTML comments visible to users?" is a good practical-knowledge check — many beginners assume comments are fully hidden the way server-side comments are.

Practice Question

Comment out a navigation menu item that links to a page still under construction, without deleting the code.

Related HTML Notes

Want to go beyond the notes?

Join CodingNow's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →