← Back to HTML Course | Chapter 1: Introduction & Basics | Lesson 6 of 11

HTML Headings

कल्पना कीजिए एक अखबार खोलना जहां हर एक शब्द बिल्कुल एक ही size, weight, और font में print हुआ हो। आपको सिर्फ यह जानने के लिए कि articles किस बारे में हैं, हर वाक्य पढ़ना पड़ेगा। यह बेहद frustrating होगा। HTML headings आपकी digital headlines हैं। वे आपके page को सबसे महत्वपूर्ण topic से लेकर छोटी से छोटी detail तक structure करती हैं। वे visual signposts की तरह काम करती हैं जो आपके visitors को सेकंडों में आपका page scan करने देती हैं। इससे भी ज्यादा महत्वपूर्ण बात, headings एक structured map बनाती हैं जो Google जैसे search engines को आपकी website के main theme को समझने में मदद करता है।
Syntax
markup
<h1>Heading text</h1>
<h2>Heading text</h2>
<h3>Heading text</h3>

Heading Hierarchy (h1 से h6)

HTML में headings के छह levels होते हैं, जो सबसे बड़े और सबसे महत्वपूर्ण h1 से शुरू होकर सबसे छोटे h6 तक जाते हैं। यह hierarchy आपके content के लिए महत्व का एक स्पष्ट क्रम स्थापित करती है, जो किसी किताब के chapters और sub-chapters जैसा होता है।

Note: अपने document के main topic को दर्शाने के लिए per page सिर्फ एक h1 का उपयोग करें।
Warning: h1 से सीधे h3 पर जाने जैसे heading levels को skip न करें क्योंकि इससे structural flow टूट जाता है।

उदाहरण: The Heading Hierarchy (h1 to h6)

markup
<h1>Main Title</h1>
<h2>Section</h2>
<h3>Subsection</h3>
<h4>Sub-subsection</h4>
<h5>Minor heading</h5>
<h6>Smallest heading</h6>

SEO के लिए Headings क्यों मायने रखते हैं

Search engines आपकी website को पढ़ने, categorize करने, और index करने के लिए headings का उपयोग करते हैं। अगर आप अपनी headings को relevant keywords के साथ ठीक से structure करते हैं, तो search bots आसानी से यह पता लगा सकते हैं कि आप कौन-सी services या products offer करते हैं।

Note: अपने main target keywords को अपने h1 और h2 tags के अंदर स्वाभाविक रूप से शामिल करें।
Warning: headings में बहुत सारे keywords ठूंसने से बचें क्योंकि search engines इसे spam के रूप में flag कर देंगे।

उदाहरण: Why Headings Matter for SEO

markup
<h1>Affordable Web Hosting Plans</h1>
<h2>Shared Hosting Pricing</h2>

Accessibility और Screen Readers

दृष्टिबाधित users अक्सर websites navigate करने के लिए screen readers जैसी assistive technologies पर निर्भर करते हैं। ये devices users को content को skim करने के लिए heading से heading पर jump करने देते हैं, जिससे सही heading structures ज़रूरी बन जाती हैं।

Note: अपनी headings को इतना descriptive बनाएं कि वे context से बाहर पढ़े जाने पर भी समझ में आएं।
Warning: असली heading tags की जगह bold paragraph tags का उपयोग कभी न करें क्योंकि screen readers fast navigation के दौरान उन्हें नजरअंदाज कर देंगे।

उदाहरण: Accessibility and Screen Readers

markup
<h1>Article Title</h1>
<h2>Introduction</h2>
<h2>Conclusion</h2>

Headings Structural हैं, Visual नहीं

एक आम गलती है सिर्फ इस आधार पर heading tag चुनना कि वह ब्राउज़र में कितना बड़ा दिखता है। Headings को structural relationships दर्शाना चाहिए। अगर आपको बड़ा या छोटा text चाहिए, तो उसे हमेशा CSS का उपयोग करके control करें।

Note: अपने text को style करने के लिए heading tags का गलत उपयोग करने के बजाय CSS font-size properties का उपयोग करें।
Warning: non-heading text को सिर्फ bold या prominent बनाने के लिए heading tags में wrap न करें।

उदाहरण: Headings are Structural, Not Visual

markup
<h2>Correct: Structural Heading</h2>
<p style="font-size: 24px;">Large text without using a heading tag</p>

Default Spacing और Margins प्रबंधित करना

ब्राउज़र headings को आसपास के paragraphs से अलग करने के लिए headings के ऊपर और नीचे स्वचालित रूप से पहले से set margins जोड़ते हैं। इन default styles को समझने से elements को arrange करते समय layout संबंधी आश्चर्यों से बचा जा सकता है।

Note: जब आपको elements को एक-दूसरे के पास रखने की ज़रूरत हो, तो default margins को zero करने के लिए inline या external CSS का उपयोग करें।
Warning: browser की default spacing पर पूरी तरह भरोसा करने से आपके layouts अलग-अलग mobile devices पर असंगत दिख सकते हैं।

उदाहरण: Managing Default Spacing and Margins

markup
<h2 style="margin: 0;">Heading with margins removed</h2>
<p>Paragraph sitting closer to the heading above.</p>
Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
🔒

Chapter Quiz — Complete all 11 topics to unlock

0/11 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.