Comments & Whitespace
<!-- 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>- <!-- 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
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><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 -->