💬
Basics

Comments & Whitespace

<!-- --> Aur Formatting
💡 HTML comments (<!-- -->) invisible sticky notes hain — sirf code padhne walon (developers) ke liye, browser inhe completely ignore karta hai, user ko kabhi nahi dikhte.

<!-- comment text --> se HTML mein comments likhte hain — notes chhodne ke liye, ya temporarily kuch code disable karne ke liye. Browser inhe render nahi karta, koi user-visible effect nahi.

HTML extra whitespace (multiple spaces, newlines) ko IGNORE karta hai — browser sab ko ek single space treat karta hai. Isliye HTML code ko indent/format karna sirf readability ke liye hai, output par koi effect nahi.

<!-- Ye ek comment hai, browser ise ignore karega -->
<p>Ye text dikhega.</p>

<!-- <p>Ye temporarily disabled hai</p> -->

<!-- Multiple spaces/newlines ek space jaisa hi treat hote hain: -->
<p>Ye     text      normal
   spacing    ke   saath dikhega</p>
💬
HTML comments (<!-- -->) invisible sticky notes hain — sirf code padhne walon (developers) ke liye, browser inhe completely ignore karta hai, user ko kabhi nahi dikhte.
1 / 2
⚡ झट से Recap
  • <!-- comment --> = developer notes, browser ignore karta hai
  • Extra whitespace HTML mein collapse ho jaata hai (single space)
  • <pre> tag exact spacing preserve karta hai jab zaroorat ho
इस page में (2 subtopics)

Comments ek bahut common debugging technique hain — agar kisi section ko temporarily hatana ho (bina delete kiye) ye check karne ke liye ki wo kisi problem ki wajah hai ya nahi, usse comment mein wrap kar do.

<div class="header">
  <!-- <div class="promo-banner">Sale! 50% off</div> -->
  <!-- upar wala banner temporarily disable kiya gaya hai testing ke liye -->
  <nav>...</nav>
</div>
💡Tip: Comments ko production code mein permanently "disabled code" ke liye chhod dena bad practice hai — agar genuinely delete karna hai, version control (git) already history rakhta hai, comment mein rakhne ki zaroorat nahi.

<pre> ("preformatted") tag ke andar, HTML whitespace collapse NAHI karta — exact spacing, line breaks preserve hote hain jaise likhe gaye hain. Code snippets dikhane ke liye bahut common (usually <code> ke saath combine hota hai).

<pre><code>function greet() {
    console.log("Hello");
}</code></pre>

<!-- Ye exact indentation/line-breaks ke saath dikhega,
     normal <p> tag mein sab ek line mein collapse ho jaata -->
💡Tip: <pre> default monospace font use karta hai (jaise Courier) — code snippets ke liye visually bhi appropriate lagta hai.