Chapter 310m

HTML Elements in Hindi

हिन्दी में HTML Elements सीखें। Start Tag, End Tag, Nested Elements, Void Elements और Correct HTML Structure को आसान Examples से समझें।

पिछले Chapter में आपने Headings, Paragraphs, Links, Images और Buttons के Basic Examples सीखे थे।

अब समझते हैं कि इन सभी को बनाने वाले HTML Elements कैसे काम करते हैं।

HTML Elements किसी Web Page के Building Blocks होते हैं। ये Page के अलग-अलग हिस्सों का Structure और Meaning निर्धारित करते हैं।

इस Chapter में आप Start Tag, End Tag, Element Content, Nested Elements, Void Elements और सही HTML Structure के बारे में सीखेंगे।

HTML Element क्या है?

सामान्यतः एक HTML Element में Start Tag, Content और End Tag होते हैं।

Syntax:

html
<tagname>Content goes here...</tagname>

Example:

html
<h1>Welcome to HTML</h1>
Partविवरण
\<h1>Start Tag — Element की शुरुआत दर्शाता है।
Welcome to HTMLElement Content — Element के अंदर मौजूद Text।
\</h1>End Tag — Element का अंत दर्शाता है।

Important: HTML Tag और HTML Element बिल्कुल एक ही चीज़ नहीं हैं। Tags, Element को परिभाषित करने वाले Syntax का हिस्सा होते हैं।

Start Tags और End Tags

अधिकांश HTML Elements में Start Tag और End Tag दोनों होते हैं।

End Tag में Tag Name से पहले / लगाया जाता है।

Example:

html
<p>This is a paragraph.</p>

यहाँ <p> Start Tag है और </p> End Tag है।

एक अन्य Example:

html
<h2>About Me</h2>
<p>I am learning HTML.</p>

हालाँकि सभी HTML Elements में End Tag नहीं होता। कुछ Elements को Void Elements कहा जाता है।

Nested HTML Elements

जब एक HTML Element के अंदर दूसरा Element रखा जाता है, तो उसे Nested Element कहते हैं।

Example:

html
<p>
    I am learning <strong>HTML</strong> today.
</p>

यहाँ:

  • <p> Parent Element है।
  • <strong> इसके अंदर मौजूद Child Element है।
  • <strong> अपने Content को विशेष महत्व देता है। Browser सामान्यतः इसे Bold दिखाता है।

एक अन्य Example:

html
<div>
    <h2>My Profile</h2>
    <p>Welcome to my website.</p>
</div>

इसमें <h2> और <p>, दोनों <div> के अंदर Nested हैं।

<div> एक Generic Container Element है।

HTML Document में Nested Elements

एक Complete HTML Document में भी कई Elements एक-दूसरे के अंदर मौजूद होते हैं।

html
<!DOCTYPE html>
<html>
<head>
    <title>HTML Elements</title>
</head>
<body>
    <h1>My First Heading</h1>
    <p>My first paragraph.</p>
</body>
</html>

Structure Explained:

  • <html> Document का Root Element है।
  • <head> और <body>, <html> के Child Elements हैं।
  • <title>, <head> के अंदर है।
  • <h1> और <p>, <body> के अंदर हैं।

ध्यान दें: <!DOCTYPE html> एक Declaration है, HTML Element नहीं।

End Tag लिखना क्यों ज़रूरी है?

कुछ HTML Elements के End Tags विशेष परिस्थितियों में छोड़े जा सकते हैं, लेकिन Beginners को स्पष्ट और सही Closing Tags लिखने की आदत डालनी चाहिए।

Recommended:

html
<p>This is my first paragraph.</p>
<p>This is my second paragraph.</p>

HTML कुछ परिस्थितियों में </p> को छोड़ने की अनुमति देता है, लेकिन हर End Tag Optional नहीं होता।

स्पष्ट Closing Tags से Code पढ़ना और Debug करना आसान होता है।

Void Elements क्या हैं?

कुछ HTML Elements Child Content नहीं रख सकते और उनका End Tag नहीं होता। इन्हें Void Elements कहते हैं।

Elementउपयोग
\<br>Line Break जोड़ता है।
\<hr>Thematic Break दर्शाता है।
\<img>Image Embed करता है।
\<input>Input Control बनाता है।
\<meta>Document Metadata देता है।
\<link>External Resource जोड़ता है।

Example:

html
<p>Hello<br>World!</p>

Image Example:

html
<img src="photo.jpg" alt="A landscape photograph">

<img> के लिए </img> लिखने की आवश्यकता नहीं होती।

HTML Syntax में <br /> जैसा Trailing Slash भी लिखा जा सकता है, लेकिन यह अनिवार्य नहीं है और Closing Tag नहीं बनाता।

HTML Tag Names और Letter Case

Standard HTML Syntax में Tag Names Case-insensitive होते हैं।

ये दोनों Paragraph Elements के रूप में पहचाने जाते हैं:

html
<P>This is a paragraph.</P>
html
<p>This is a paragraph.</p>

Recommended Practice: HTML Tag Names हमेशा Lowercase में लिखें।

text
<h1>My Website</h1>
<p>Welcome to my website.</p>

इससे Code Consistent और Readable रहता है।

सही Nesting कैसे करें?

Nested Elements को सही क्रम में Close करना चाहिए।

Incorrect:

html
<p>This is <strong>important.</p></strong>

Correct:

html
<p>This is <strong>important.</strong></p>

नियम सरल है: अंदर वाला Element पहले Close करें, उसके बाद बाहर वाला Parent Element।

Block और Inline Elements की पहली समझ

कुछ HTML Elements Browser में सामान्यतः अलग Blocks के रूप में दिखते हैं।

html
<h2>My Heading</h2>
<p>My paragraph.</p>

वहीं <strong> जैसा Element सामान्यतः उसी Text Line के अंदर दिखाई देता है:

html
<p>
    Learn <strong>HTML</strong> with W3PrimeCode.
</p>

यह Block और Inline Display Behavior का शुरुआती परिचय है। CSS की सहायता से Display Behavior बदला जा सकता है।

Complete Practical Example

html
<!DOCTYPE html>
<html>
<head>
    <title>Understanding HTML Elements</title>
</head>
<body>

    <div>
        <h1>Welcome to My Website</h1>

        <p>
            I am learning <strong>HTML</strong>
            with W3PrimeCode.
        </p>

        <hr>

        <h2>My Introduction</h2>

        <p>
            My name is Alex.<br>
            I want to become a Web Developer.
        </p>

        <img
            src="https://www.w3.org/Icons/w3c_home"
            alt="W3C Logo"
            width="100"
        >
    </div>

</body>
</html>

Expected Output: Browser में Main Heading, Bold Text वाला Paragraph, Thematic Break, दूसरी Heading, Line Break वाला Paragraph और Image (Resource उपलब्ध होने पर) दिखाई देंगे।

इस Example में Nested Elements और <hr>, <br>, <img> जैसे Void Elements एक साथ उपयोग किए गए हैं।

Common Beginner Mistakes

Mistake 1: End Tag भूलना

Incorrect:

html
<h1>Welcome to HTML

Correct:

html
<h1>Welcome to HTML</h1>

Mistake 2: गलत Nesting

Incorrect:

html
<p>Hello <strong>World</p></strong>

Correct:

html
<p>Hello <strong>World</strong></p>

Mistake 3: Void Element के लिए End Tag लिखना

Incorrect:

html
<br></br>

Correct:

html
<br>

Mistake 4: Tag और Element को एक ही समझना

Tag, HTML Syntax का हिस्सा है। Element उस Syntax से निर्धारित पूरी Structure है।

Try It Yourself

html-elements.html नाम की File बनाएँ।

html
<!DOCTYPE html>
<html>
<head>
    <title>HTML Elements Practice</title>
</head>
<body>

    <h1>My Profile</h1>

    <p>
        My name is <strong>Your Name</strong>.
    </p>

    <hr>

    <p>
        I am learning HTML.<br>
        This is my practice page.
    </p>

</body>
</html>

आपके Tasks:

  1. Your Name की जगह अपना नाम लिखें।
  2. एक <h2> Heading जोड़ें।
  3. <body> में नया Paragraph बनाएँ।
  4. Heading और Paragraph को एक <div> में रखें।
  5. Meaningful alt Text के साथ Image जोड़ें।
  6. सभी Nested Elements का Closing Order जाँचें।
  7. File Save करके Browser में Output देखें।