Chapter 210m

HTML Basic in Hindi

हिन्दी में HTML Basic सीखें। Headings, Paragraphs, Links, Images, Buttons और Attributes के Code Examples के साथ HTML Practice करें।

पिछले Chapter में आपने HTML File बनाना, Save करना और Browser में Open करना सीखा था।

अब हम HTML के कुछ Basic सीखेंगे।

इस Chapter में आप Headings, Paragraphs, Links, Images, Buttons और अन्य सामान्य HTML Elements का उपयोग करके अपना पहला Web Page तैयार करेंगे।

Basic HTML Document

एक सामान्य HTML Page का Structure इस प्रकार होता है:

Example:

html
<!DOCTYPE html>
<html>
<head>
    <title>My First HTML Page</title>
</head>
<body>
    <h1>Welcome to W3PrimeCode</h1>
    <p>This is my first HTML page.</p>
</body>
</html>

Code Explanation

Codeविवरण
\<!DOCTYPE html>Document में HTML5 उपयोग होने की घोषणा करता है।
\<html>HTML Document का Root Element है।
\<head>Document की Metadata रखता है।
\<title>Browser Tab का Title निर्धारित करता है।
\<body>मुख्य Visible Content रखता है।
\<h1>Top-level Heading बनाता है।
\<p>Paragraph बनाता है।

HTML Headings

HTML में Headings बनाने के लिए <h1> से <h6> तक छह Levels उपलब्ध हैं।

<h1> सबसे उच्च स्तर की Heading और <h6> सबसे निम्न स्तर की Heading दर्शाता है।

Example:

html
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

Expected Output: Browser सभी छह Headings को उनके Default Styles के अनुसार अलग-अलग Sizes में दिखाएगा।

Important: Heading का चुनाव Content की Hierarchy के अनुसार करें, केवल Text बड़ा या छोटा दिखाने के लिए नहीं।

HTML Paragraphs

<p> Element का उपयोग Paragraph बनाने के लिए किया जाता है।

Example:

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

Browser सामान्यतः दोनों Paragraphs को अलग-अलग Blocks में दिखाता है।

HTML Links

HTML में एक Page से दूसरे Page या Resource तक जाने के लिए Hyperlinks का उपयोग किया जाता है।

Link बनाने के लिए <a> Element इस्तेमाल होता है।

Syntax:

html
<a href="URL">Link Text</a>

Example:

html
<a href="https://www.example.com">
    Visit Example Website
</a>

Code Explanation:

  • <a> Hyperlink बनाता है।
  • href Attribute, Link का Destination बताता है।
  • Visit Example Website Click करने योग्य Text है।

Link पर Click करने से Browser निर्धारित URL पर जाता है।

HTML Images

Web Page में Image जोड़ने के लिए <img> Element उपयोग किया जाता है।

Syntax:

html
<img src="image.jpg" alt="Image description">

Example:

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

Expected Output: Image Resource उपलब्ध होने पर Browser W3C Logo दिखाएगा।

Attributes Explained

Attributeउपयोग
srcImage का Location निर्धारित करता है।
altImage का Text Alternative प्रदान करता है।
widthImage की Display Width निर्धारित करता है।

alt Attribute Accessibility के लिए महत्वपूर्ण है। Image Load नहीं होने पर भी यह उसके उद्देश्य या Content की जानकारी देने में मदद करता है।

<img> एक Void Element है। इसे Closing Tag की आवश्यकता नहीं होती।

HTML Buttons

Button बनाने के लिए <button> Element उपयोग किया जाता है।

Example:

html
<button type="button">Click Me</button>

Expected Output: Browser में Click Me Text वाला Button दिखाई देगा।

यह Button अपने आप कोई Custom Action नहीं करता। आगे JavaScript की सहायता से इसमें Interactivity जोड़ सकते हैं।

HTML Line Breaks

<br> Element Text के बीच Line Break जोड़ता है।

Example:

html
<p>
    Hello World!<br>
    Welcome to HTML.
</p>

<br> एक Void Element है। इसका Closing Tag नहीं होता।

केवल Page Layout में खाली जगह बनाने के लिए बार-बार <br> का उपयोग नहीं करना चाहिए। इसके लिए CSS अधिक उपयुक्त है।

HTML Horizontal Rules

<hr> Element, Content के दो Sections के बीच Thematic Break दर्शाता है।

Example:

html
<h2>HTML Tutorial</h2>
<p>Learn HTML step by step.</p>

<hr>

<h2>CSS Tutorial</h2>
<p>Learn how to style web pages.</p>

Expected Output: Browser सामान्यतः दोनों Sections के बीच एक Horizontal Line दिखाता है।

HTML Attributes

HTML Attributes किसी Element के बारे में अतिरिक्त जानकारी या Configuration प्रदान करते हैं।

इन्हें सामान्यतः Start Tag में लिखा जाता है।

Syntax:

html
<tagname attribute="value">Content</tagname>

Example:

html
<a href="https://www.example.com">Visit Website</a>

यहाँ href एक Attribute है।

एक अन्य Example:

html
<p title="This is a tooltip">
    Move your mouse over this paragraph.
</p>

कई Desktop Browsers में Mouse Hover करने पर title की जानकारी Tooltip के रूप में दिखाई दे सकती है।

HTML Source Code कैसे देखें?

किसी Web Page का HTML Source देखने के लिए Desktop Browser में View Page Source विकल्प उपयोग कर सकते हैं।

सामान्य Keyboard Shortcuts:

  • Windows/Linux: Ctrl + U
  • macOS: Supported Browsers में Option + Command + U

किसी विशेष Element की जाँच करने के लिए उस पर Right-click करके Inspect चुनें।

ध्यान दें: View Page Source सामान्यतः प्राप्त Original HTML दिखाता है, जबकि Inspect वर्तमान DOM दिखाता है, जिसमें JavaScript द्वारा किए गए बदलाव भी शामिल हो सकते हैं।

Complete Practical Example

अब विभिन्न HTML Elements को एक Page में जोड़ते हैं।

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

    <h1>Welcome to My Website</h1>

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

    <h2>About HTML</h2>

    <p>HTML is used to structure web content.</p>

    <hr>

    <h2>Useful Link</h2>

    <a href="https://www.example.com">
        Visit Example Website
    </a>

    <h2>Sample Image</h2>

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

    <h2>Button Example</h2>

    <button type="button">Click Me</button>

</body>
</html>

Expected Output: Browser में Headings, Paragraphs, एक Horizontal Line, Clickable Link, Image (यदि Resource Load हो) और Button दिखाई देंगे।

यह Example बताता है कि विभिन्न HTML Elements मिलकर एक Web Page कैसे बनाते हैं।

Common Beginner Mistakes

Mistake 1: Closing Tag भूलना

Incorrect:

html
<h1>Welcome
<p>Hello World</p>

Correct:

html
<h1>Welcome</h1>
<p>Hello World</p>

Mistake 2: Attribute Values में Quotes न लगाना

HTML कुछ परिस्थितियों में बिना Quotes के Values स्वीकार करता है, लेकिन Consistency के लिए Quotes उपयोग करना Recommended है।

text
<a href="https://www.example.com">Visit Website</a>

**Mistake 3: Image में alt न देना**

Informative Image के लिए:

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

Mistake 4: केवल Font Size बदलने के लिए Headings उपयोग करना

Headings का उपयोग Content Hierarchy दर्शाने के लिए करें। Appearance बदलने के लिए CSS उपयोग करें।

Try It Yourself

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

Starter Code:

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

    <h1>My First Website</h1>

    <p>Write your introduction here.</p>

    <h2>My Favorite Website</h2>

    <a href="https://www.example.com">
        Visit Website
    </a>

</body>
</html>

आपके Tasks:

  1. Main Heading बदलें।
  2. दो नए Paragraphs जोड़ें।
  3. एक नई <h2> Heading बनाएँ।
  4. अपनी पसंद की Website का Link जोड़ें।
  5. <img> से Image जोड़ें।
  6. एक Button बनाएँ।
  7. File Save करके Browser में Output देखें।