HTML Comments

HTML Comments code के अंदर लिखे गए notes होते हैं जो browser में display नहीं होते
इनका उपयोग code को समझाने, documentation बनाने और future reference के लिए किया जाता है।

Comments developer के लिए होते हैं, user के लिए नहीं।

HTML Comment Syntax

HTML comment लिखने का syntax:

<!-- This is a comment -->

Browser इस comment को ignore करता है और page output में नहीं दिखाता।

Single-Line Comment

Single-line comment एक line में लिखा जाता है।

Example:

<!-- Header section starts -->

Multi-Line Comment

Multi-line comment multiple lines में लिखा जा सकता है।

Example:

<!--
This is a multi-line comment
HTML comments are ignored by browser
-->

HTML Comments कहाँ Use होते हैं?

HTML comments का उपयोग किया जाता है:

  • Code explanation के लिए
  • Section identify करने के लिए
  • Temporary code disable करने के लिए
  • Debugging में मदद के लिए

HTML Code को Comment करना

किसी HTML code को temporarily hide करने के लिए उसे comment किया जा सकता है।

Example:

<!-- <p>This paragraph is hidden</p> -->

Browser इस paragraph को render नहीं करेगा।

HTML Comments और Debugging

जब page में error आती है:

  • Code sections को comment करके test किया जाता है
  • Issue identify करना आसान होता है

HTML Comments और SEO

Important points:

  • Comments search engines के लिए content नहीं होते
  • Comments में keywords डालने से SEO benefit नहीं मिलता
  • Sensitive information comments में कभी न लिखें

HTML Conditional Comments (Deprecated)

Internet Explorer में पहले conditional comments use होते थे:

<!--[if IE]>
<p>Only for Internet Explorer</p>
<![endif]-->

यह अब obsolete हो चुके हैं।

Common Beginner Mistakes

  • Comment के अंदर comment लिखना (nested comments)
  • Sensitive data comment में छोड़ देना
  • Excessive commenting
  • Closing --> भूल जाना

HTML Comments Best Practices

  • Short और meaningful comments लिखें
  • Complex sections को explain करें
  • Unnecessary comments avoid करें
  • Production code में clean comments रखें

Quick Summary

  • HTML comments browser में दिखाई नहीं देते
  • Comments code readability बढ़ाते हैं
  • Debugging और documentation में helpful हैं
  • SEO पर direct impact नहीं डालते

Practice Questions

  1. HTML comment क्या होता है?
  2. Comment syntax क्या है?
  3. Comments SEO को क्यों affect नहीं करते?

Share your love