HTML में Style Attribute का उपयोग कैसे करें

Style attribute HTML में एक attribute है, जिसका उपयोग किसी specific element पर CSS (Cascading Style Sheets) को directly लागू करने के लिए किया जाता है। यह attribute inline CSS को define करता है और HTML element के साथ-साथ उसकी styling को एक ही जगह पर specify करता है।

HTML में Style Attribute का उपयोग कैसे करें


HTML में किसी element की style सेट करने के लिए style attribute का उपयोग किया जाता है। यह attribute CSS properties को inline तरीके से HTML element पर लागू करता है।

Syntax:

<tagname style="property:value;">Content

</tagname>

<tagname>: HTML element का नाम (जैसे <p>, <h1>, <div>)।

style: यह attribute है, जिसका उपयोग CSS properties को define करने के लिए होता है।

property:value;: CSS की property और उसका मान, जिसे आप लागू करना चाहते हैं।

Note: CSS properties और values को semicolon (;) से अलग किया जाता है।

Example:

<!DOCTYPE html>

<html>

<body>


<h1 style="color:blue;">This is a blue heading</h1>

<h2 style="color:green;">This is a green heading.</h2>

<P style="background-color: yellow;">This is a yellow background.</p>


</body>


</html>

इस कोड का output इस प्रकार होगा।
Style Attribute Example

This is a blue heading

This is a green paragraph with larger text.

This is a div with yellow background.


दो अलग अलग elements के लिए background colour

<!DOCTYPE html>
<html>
<body>

<h1 style="background-color: green;">This is a heading</h1>
<p style="background-color:pink;">This is a paragraph.</p>

</body>
</html>

ऊपर वाले कोड के लिये आउटपुट

This is a heading

This is a paragraph.

पेज के लिए background colour

<!DOCTYPE html>
<html>
<body style="background-color:lightblue;">

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>
 

HTML element के text के लिए font

font-family प्रॉपर्टी का उपयोग किसी HTML element के text के लिए font सेट करने के लिए किया जाता है।

यह प्रॉपर्टी बताती है कि टेक्स्ट को किस font style में दिखाना है। यदि पहला font उपलब्ध न हो, तो browser दूसरा font उपयोग करता है।

Syntax:

font-family: "font1", "font2", generic-family;

font1: प्राथमिक (primary) font।
font2: वैकल्पिक (fallback) font।
generic-family: एक सामान्य श्रेणी का font (जैसे, serif, sans-serif, monospace)।
नोट: ब्राउज़र fallback font तभी उपयोग करता है, जब प्राथमिक font उपलब्ध न हो।


<!DOCTYPE html>

<html>

<body>

<h1 style="font-family:times new roman;">This is a heading</h1>

<p style="font-family:verdana;">This is a paragraph.</p>

</body>

</html>

ऊपर वाले code का output

This is a heading

This is a paragraph.


Text-Size  

font-size प्रॉपर्टी का उपयोग HTML element के text की size (आकार) सेट करने के लिए किया जाता है। यह प्रॉपर्टी बताती है कि text छोटा, बड़ा या medium आकार का दिखना चाहिए। इसे अलग-अलग units (जैसे pixels, em, rem, percentages) में specify किया जा सकता है।

Syntax:

font-size: value;


  • Absolute Sizes:

    • xx-small, x-small, small, medium, large, x-large, xx-large
    • ये fixed sizes होती हैं।
  • Relative Sizes:

    • smaller, larger (parent element के relative)।
  • Length Units:

    • px (pixels), em, rem, %, vw, vh
    • ये responsive और flexible sizes के लिए उपयोग होती हैं।
  • Example:

    <!DOCTYPE html>
    <html>
    <body>

    <h1 style="font-size:300%;">This is a heading</h1>
    <p style="font-size:160%;">This is a paragraph.</p>

    </body>
    </html>

    ऊपर वाले code का output 

    This is a heading

    This is a paragraph.

    Example:

    <!DOCTYPE html>
    <html>
    <body>

    <h1 style="font-size:1000%;">XXX</h1>

    </body>
    </html>

    ऊपर वाले code का output 

    XXX


    text-align

    text-align प्रॉपर्टी का उपयोग किसी HTML element के text को horizontally (क्षैतिज रूप से) align करने के लिए किया जाता है।

    यह प्रॉपर्टी यह निर्धारित करती है कि text left, right, center, या justify alignment में दिखेगा।

    Syntax:

    text-align: value;

    Values:

    1. left: Text को बाईं तरफ align करता है।
    2. right: Text को दाईं तरफ align करता है।
    3. center: Text को center में align करता है।
    4. justify: Text को दोनों किनारों पर align करता है, जिससे text एक column जैसा दिखता है।
    5. start: Text को document के default प्रारंभिक दिशा में align करता है (LTR या RTL पर निर्भर)।
    6. end: Text को document की default अंतिम दिशा में align करता है।
    Example:

    <!DOCTYPE html>

    <html>

    <body>

    <h1 style="text-align:center;">Centered Heading</h1>
    <h2 style="text-align:left;">left Heading</h2>

    <p style="text-align:right;">right paragraph.</p>


    </body>

    </html>

    इस code का output 

    Centered Heading

    left Heading

    right paragraph.

    size and colour


    Size and colour का use साथ साथ कैसे होता है देखिए।

    <!DOCTYPE html>
    <html>
    <body>

    <h1 style="color:blue;font-size:900%;">XXXXX</h1>

    </body>
    </html>

    इस code का output 

    XXXX

    Different Colour


    <!DOCTYPE html>
    <html>
    <body>

    <h1>
        <span style="color:red; font-size:900%;">X</span>
        <span style="color:blue; font-size:900%;">X</span>
        <span style="color:green; font-size:900%;">X</span>
        <span style="color:orange; font-size:900%;">X</span>
    </h1>

    </body>
    </html>

    इस code का output 

    X X X X

    Colour Animation:


    <!DOCTYPE html>
    <html>
    <head>
        <style>
            /* Animation for changing colors */
            @keyframes colorChange {
                0% { color: red; }
                25% { color: blue; }
                50% { color: green; }
                75% { color: orange; }
                100% { color: red; }
            }

            /* Common style for each X */
            .animated {
                font-size: 900%; /* Font size set to 900% */
                animation: colorChange 4s infinite; /* Animation duration is 4 seconds */
            }

            /* Adding delay for individual spans */
            .x1 { animation-delay: 0s; }
            .x2 { animation-delay: 1s; }
            .x3 { animation-delay: 2s; }
            .x4 { animation-delay: 3s; }
        </style>
    </head>
    <body>

    <h1>
        <span class="animated x1">X</span>
        <span class="animated x2">X</span>
        <span class="animated x3">X</span>
        <span class="animated x4">X</span>
    </h1>

    </body>
    </html>

    इस code का आउटपुट:

    X X X X

     

    HTML में Style Attribute का उपयोग कैसे करें

    HTML में Style Attribute का उपयोग किसी भी element की styling को control करने के लिए एक आसान और प्रभावी तरीका है। यह attribute inline styling के लिए उपयोग होता है, जो specific element की appearance को तुरंत बदलने में मदद करता है। 

    चाहे text का color बदलना हो, font size सेट करना हो, या background color जोड़ना हो, Style Attribute HTML को अधिक आकर्षक और user-friendly बनाने में सहायक है। हालांकि, बड़े प्रोजेक्ट्स में maintainability के लिए CSS files का उपयोग बेहतर होता है।

    Read Also 










    Code द्वारा google drive की images कैसे show करें

    Google Drive की image को HTML में img tag और src attribute के माध्यम से उपयोग करना थोड़ा tricky हो सकता है, क्योंकि Google Drive की direct URLs embed के लिए काम नहीं करतीं। नीचे स्टेप्स दिए गए हैं, जो आपको इसे सही तरीके से उपयोग करने में मदद करेंगे:

    सबसे पहले, अपनी image को Google Drive में अपलोड करें।

    Image की Shareable Link Generate करें:

    Google Drive में image पर right-click करें।

    Manage access विकल्प चुनें।

    Link को "Anyone with the link" पर सेट करें और Copy करें।

    Code द्वारा google drive की images कैसे show करें

    एक popup खुलेगा जिसमें लिखा होगा "Restricted" या "Anyone with the link"।

    "Restricted" को बदलकर "Anyone with the link" कर दें।

    Permission को "Viewer" पर सेट करें ताकि users image को केवल देख सकें।

    "Copy Link" पर क्लिक करें और इसे save कर लें।


    Embed Link Generate करें (Optional):

    अगर आप image को HTML में img tag के लिए उपयोग करना चाहते हैं, तो इस link को embed format में बदलें:

    Example के तौर पर मैं google drive पर पड़ी हुई एक image का example link प्रस्तुत कर रहा हूं।

    Example link 

    https://drive.google.com/file/d/1jwGaO0vphMV4CKVMvcj4O1TU7o1ATvkD/view?usp=drivesdk

    Embed Format 

    https://drive.google.com/uc?export=view&id=1jwGaO0vphMV4CKVMvcj4O1TU7o1ATvkD

    Embed format का मतलब

    Embed Format का मतलब है किसी external resource (जैसे image, video, audio, या document) को किसी अन्य प्लेटफ़ॉर्म या webpage में शामिल करना, ताकि वह content उसी पेज पर directly दिखाई या चल सके।

    यह external content को link करने के बजाय उसे webpage में seamlessly integrate करने का तरीका है।

    Complete code:

    <!DOCTYPE html>

    <html>

    <body>

        <h1>Google Drive से Image</h1>

        <p>नीचे दी गई image Google Drive से embed की गई है:</p>

        <img src="https://drive.google.com/uc?export=view&id=1jwGaO0vphMV4CKVMvcj4O1TU7o1ATvkD" alt="Google Drive Image" width="500">

    </body>

    </html>


    कोड को किसी text editor के html सेक्शन में सेव करें।

    Browser में फाइल को ओपन करें।

    यदि image अभी भी शो नहीं हो रही है, तो निम्न जांचें:

    Embed Link को फिर से Validate करें।

    Public Link Confirm करें।

    अगर सभी settings सही हैं और image नहीं दिख रही है, तो Google Drive की link embedding में समस्या हो सकती है। इस स्थिति में, आप निम्न विकल्प ट्राई करें:

    Image को अन्य hosting platform (जैसे Imgur) पर अपलोड करें।

    उस hosting platform का direct URL उपयोग करें।

    Embed Format का महत्व:

    Seamless Integration:

    External content को webpage पर directly दिखाने का आसान तरीका।

    Dynamic Content:

    Videos, audios, documents, और images को dynamically load किया जा सकता है।

    User-Friendly Experience:

    Users को अलग-अलग platforms पर जाने की ज़रूरत नहीं होती।

    Code द्वारा Google Drive की Images कैसे Show करें 

    Google Drive पर उपलब्ध images को वेबपेज पर दिखाना एक आसान प्रक्रिया है, लेकिन इसमें सही कोड और लिंक फॉर्मेट का उपयोग करना आवश्यक है। सबसे पहले, Google Drive में image की visibility को "Anyone with the link" पर सेट करना होता है ताकि image publically accessible हो। इसके बाद, image के लिंक से उसका File ID निकालकर उसे embed format में बदलें, जैसे:

    https://drive.google.com/uc?export=view&id=FILE_ID

    इसके बाद, HTML कोड में <img> टैग का उपयोग करके image को वेबपेज पर दिखाया जा सकता है। उदाहरण के लिए:

    <img src="https://drive.google.com/uc?export=view&id=FILE_ID" alt="Image Description" width="500">

    इस प्रक्रिया के माध्यम से आप Google Drive की images को seamless तरीके से अपने वेबपेज पर embed कर सकते हैं। यह तरीका user-friendly और dynamic web content बनाने के लिए अत्यंत उपयोगी है।


    Read Also 

    HTML Attributes Kya Hai? Beginners ke liye complete guide

    HTML Basic Guide for Beginners in Hindi

    Best HTML Editors Website बनाने के लिए

    HTML Kya Hai ? Main Elements of HTML in Hindi

    HTML में Style Attribute का उपयोग कैसे करें 


    Src Attribute के उपयोग

    HTML में src attribute का उपयोग किसी external resource को web page में जोड़ने के लिए किया जाता है। इसका प्रयोग मुख्य रूप से images, videos, audio files, और JavaScript files को embed करने के लिए किया जाता है। नीचे इसके प्रमुख अनुप्रयोग दिए गए हैं:
    Src attribute के उपयोग


    1. Images जोड़ने के लिए:

    src attribute image file का path बताता है।
    Example:
    <img src="image.jpg" alt="Sample Image">

    2. Videos embed करने के लिए:

    src attribute video file का URL बताता है।
    Example:
    <video src="video.mp4" controls></video>

    3. Audio Files जोड़ने के लिए:

    इसे audio files play करने के लिए use किया जाता है।
    Example:
    <audio src="audio.mp3" controls></audio>

    4. External JavaScript Files जोड़ने के लिए:

    External JavaScript को link करने के लिए src attribute का उपयोग किया जाता है।
    Example:
    <script src="script.js"></script>

    5. Iframe में External Resources Embed करने के लिए:
    Iframe में किसी external web page या resource को load किया जाता है।
    Example:

    <iframe src="https://www.example.com" width="600" height="400"></iframe>

    Key Notes:

    1. Path Specification:

    src attribute में absolute path (e.g., https://example.com/image.jpg) या relative path (e.g., images/pic.jpg) दोनों का उपयोग किया जा सकता है।

    2. Browser Requests:

    src attribute file को load करने के लिए browser को external request भेजने के लिए trigger करता है।

    src attribute HTML में multimedia और external scripts को जोड़ने का essential tool है, जिससे webpages dynamic और interactive बनते हैं।

    src attribute के अन्य उपयोग

    src attribute का उपयोग HTML में कई अन्य tags के साथ भी किया जाता है, जिससे विभिन्न resources और functionalities को web page पर लाया जा सकता है। यहां अन्य उपयोग बताए गए हैं:

    1. Input Element में (Type = "image")

    Image-based submit button बनाने के लिए src attribute का उपयोग किया जाता है।
    Example:

    <input type="image" src="button.jpg" alt="Submit Button" width="100" height="50">

    2. Source Tag के साथ (Picture और Media Elements के लिए)

    • Responsive images और videos के लिए, <source> tag में src attribute का उपयोग किया जाता है
    Example (Picture):


    <picture>
        <source src="image-large.jpg" media="(min-width: 800px)">
        <source src="image-small.jpg" media="(max-width: 799px)">
        <img src="image-default.jpg" alt="Responsive Image">
    </picture>

    Example (Video)

    <video controls>
        <source src="video.mp4" type="video/mp4">
        <source src="video.ogg" type="video/ogg">
        Your browser does not support the video tag.
    </video>
    3. Embed Tag के साथ (External Applications Embed करने के लिए)

    External applications या files (जैसे PDFs, flash files) embed करने के लिए।
    Example:


    <embed src="document.pdf" width="600" height="400">

    4. Track Tag के साथ (Captions या Subtitles के लिए)

    Videos में captions या subtitles जोड़ने के लिए।
    Example:

    <video controls>
        <source src="video.mp4" type="video/mp4">
        <track src="subtitles.vtt" kind="subtitles" srclang="en" label="English">
    </video>

    5. Object Tag के साथ (External Content Embed करने के लिए)

    External content या plugins जैसे flash और PDFs को embed करने के लिए।
    Example:

    <object data="file.pdf" type="application/pdf" width="600" height="400">
        Your browser does not support PDFs.
    </object>

    6. Iframe के Advanced Use-Cases में:

    External websites, applications, या map services जैसे content embed करने के लिए।
    Example:

    <iframe src="https://www.google.com/maps" width="600" height="400"></iframe>

    Versatility: src attribute images, videos, audios, JavaScript, external applications, और responsive resources को manage करने में versatile है।
    Optimization: सही usage से performance और user experience बेहतर होती है।

    src attribute का उपयोग HTML में multimedia, interactive elements, और external resources जोड़ने के लिए व्यापक रूप से होता है, जिससे web pages modern और dynamic बनते हैं।

    मोबाइल में पड़ी audio files को HTML में src attribute के माध्यम से कैसे use करें


    आप अपने मोबाइल में पड़ी audio files को HTML में src attribute के माध्यम से use कर सकते हैं, लेकिन इसके लिए कुछ चीजें ध्यान में रखनी होंगी:

    1. Local Audio File का Use:


    आपकी मोबाइल डिवाइस पर पड़ी ऑडियो फाइल को HTML में उपयोग करने के लिए:

    फ़ाइल का absolute path या relative path देना होगा।
    Mobile browsers पर, files को सही तरीके से access करने के लिए आपको file path को exact specify करना होगा।
    Example:


    <audio controls>
        <source src="file:///storage/emulated/0/Music/audio.mp3" type="audio/mpeg"> Your browser does not support the audio element.
    </audio>

    Limitations:

    File Path Compatibility: Mobile browsers सीधे local files को access नहीं कर सकते हैं।

    Security Restrictions: Local files को access करने के लिए browser permissions की आवश्यकता हो सकती है।

    2. File Upload और Access:

    अगर आप अपनी मोबाइल फाइल को direct use नहीं कर पा रहे हैं, तो आप इसे upload करके use कर सकते हैं:

    Cloud Storage:
    अपनी file को Google Drive, Dropbox या किसी अन्य cloud पर upload करें और public link use करें।
    Example:

    <audio controls>
        <source src="https://example.com/audio.mp3" type="audio/mpeg">
    </audio>

    Local Server Setup:
    एक local server app (जैसे Termux या HTTP Server) का उपयोग करें और फाइल को serve करें।

    • Steps:

      1. Local server app install करें।
      2. अपनी audio file को server directory में रखें।
      3. Server का URL HTML के src में उपयोग करें।
    3. Web Hosting का Use:
    यदि आप अपनी audio file को किसी वेबसाइट पर उपयोग करना चाहते हैं, तो इसे किसी web hosting platform पर upload करें।

    Example Platforms: GitHub Pages, Netlify, या अन्य hosting services।
    Example:

    <audio controls>
        <source src="https://mywebsite.com/audio.mp3" type="audio/mpeg">
    </audio>

    4. PWA (Progressive Web App) से Access:
    अगर आप offline mobile files access करना चाहते हैं:

    PWA (Progressive Web App) technology का उपयोग करें।
    Files को local storage में cache करें और फिर src में add करें।

    आप अपनी मोबाइल की audio file को HTML में use कर सकते हैं, लेकिन direct access के लिए browsers में limitations हो सकती हैं। बेहतर होगा कि आप file को upload करके या local server setup करके इस्तेमाल करें।

    Src Attribute के उपयोग:

    src attribute HTML का एक महत्वपूर्ण हिस्सा है, जिसका उपयोग multimedia elements (जैसे images, audio, video), external scripts, और अन्य resources को webpage में जोड़ने के लिए किया जाता है। यह web pages को interactive और dynamic बनाने में मदद करता है।

    मोबाइल में पड़ी फाइल्स का उपयोग करते समय, direct access की limitations हो सकती हैं। इस स्थिति में files को cloud storage या local server के माध्यम से link करना बेहतर होता है। सही configuration और hosting के साथ, आप किसी भी resource को आसानी से उपयोग कर सकते हैं।

    src attribute का प्रभावी उपयोग web development को seamless और user-friendly बनाता है।


    Read Also 













    HTML Attributes Kya Hai? Beginners ke liye complete guide

    HTML attributes वे विशेष गुण (properties) हैं जो HTML tags को अतिरिक्त जानकारी या विशेषताएं प्रदान करते हैं। ये attributes किसी भी element के व्यवहार (behavior) को नियंत्रित करते हैं या उसमें और जानकारी जोड़ते हैं। 

    HTML Attributes Kya Hai? Beginners ke liye complete guide


    Attributes हमेशा start tag में उपयोग किए जाते हैं और यह नाम (attribute name) और मान (value) की जोड़ी के रूप में लिखे जाते हैं, जैसे: attribute_name="value"। उदाहरण के लिए, 

    <img src="image.jpg" alt="Sample Image"> 

    में img एक tag है, src और alt attributes हैं।

    Attributes case-insensitive होते हैं, लेकिन HTML में lowercase लिखने की सलाह दी जाती है। एक ही element में कई attributes जोड़े जा सकते हैं, और ये हमेशा element के मतलब को स्पष्ट करने और webpage के डिज़ाइन और कार्यक्षमता को बेहतर बनाने में मदद करते हैं। जैसे, 

    <a href="https://example.com" target="_blank">Link</a> 

    में href और target attributes लिंक को दिशा और व्यवहार प्रदान करते हैं।

    कुल Attributes 

    HTML में कुल मिलाकर 100 से अधिक attributes हैं, जो अलग-अलग HTML elements के लिए उपयोग किए जाते हैं। इन attributes को उनकी उपयोगिता और कार्य के आधार पर वर्गीकृत किया जा सकता है। हालांकि, सभी attributes हर element पर लागू नहीं होते; कुछ attributes केवल विशेष tags के लिए होते हैं।

    HTML Attributes के मुख्य प्रकार:

    1. Global Attributes:
    ये attributes लगभग हर HTML element के साथ उपयोग किए जा सकते हैं। जैसे:

    id
    class
    style
    title
    data-*

    2. Specific Attributes:

    ये attributes कुछ विशेष tags के लिए होते हैं। जैसे:
    <a> tag के लिए: href, target, rel

    <img> tag के लिए: src, alt, width, height

    <form> tag के लिए: action, method, enctype

    3. Event Attributes:

    ये attributes user के interaction पर कोई event trigger करने के लिए उपयोग किए जाते हैं। जैसे:

    onclick

    onmouseover

    onkeydown

    HTML attributes की संख्या समय के साथ बढ़ती रहती है क्योंकि HTML का विकास होता रहता है। HTML5 में कई नए attributes जोड़े गए हैं, जैसे: placeholder, autofocus, और required। इसीलिए, attributes की सटीक संख्या ब्राउज़र और HTML संस्करण पर निर्भर करती है।

    Key features of html attributes

    • Extra values provide करते हैं: Attributes HTML elements का meaning clear करते हैं या उनके behaviour को adjust करते हैं।
    • हर element या tag के साथ available होते हैं: HTML का हर tag attributes का उपयोग कर सकता है।
    • हमेशा pairs में होते हैं: Attributes हमेशा name="value" के pair में लिखे जाते हैं।
    • Case-insensitive होते हैं: Attributes के नाम uppercase या lowercase में लिखे जा सकते हैं, लेकिन lowercase का उपयोग recommend किया जाता है।
    • सिर्फ start tag में use होते हैं: Attributes का प्रयोग हमेशा start tag के साथ किया जाता है, end tag के साथ नहीं।
    • Multiple attributes add किए जा सकते हैं: एक HTML element में कई attributes use किए जा सकते हैं, जैसे:
    • <input type="text" placeholder="Enter your name" required>
    • Global attributes: कुछ attributes, जैसे id, class, और style, हर HTML tag पर apply होते हैं।
    • Global attributes: कुछ attributes, जैसे id, class, और style, हर HTML tag पर apply होते हैं।
    • Element-specific attributes: कुछ attributes केवल specific tags के लिए होते हैं, जैसे <img> के लिए src और <a> के लिए href।
    • Default behaviour modify करते हैं: Attributes tags के default behaviour को change करने में मदद करते हैं, जैसे target="_blank" link को नई tab में open करता है।
    • HTML5 attributes: HTML5 ने placeholder, autofocus, और required जैसे नए attributes add किए हैं, जो user experience को बेहतर बनाते हैं।

    Important html attributes 

    आइए HTML के महत्वपूर्ण attributes पर एक नज़र डालते हैं।

    1. href Attribute 


    HTML में <a> tag का उपयोग hyperlink बनाने के लिए किया जाता है। इस tag में href attribute यह निर्धारित करता है कि लिंक किस URL या वेबपेज पर ले जाएगा। इसे "Hypertext Reference" कहा जाता है और यह attribute लिंक का path या destination तय करता है।

    href Attribute के भाग:
    href attribute दो मुख्य भागों से मिलकर बना होता है:

    • URL (Uniform Resource Locator): यह लिंक का वास्तविक पता होता है, जैसे https://example.com
    • Anchor Text (Clickable Text): यह वह पाठ या टेक्स्ट है जिसे क्लिक करके यूज़र लिंक पर जाता है, जैसे "Click Here"।

    उदाहरण:

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

    ऊपर दिए गए उदाहरण में, href="https://example.com" लिंक का पता है, और "Visit Example" वह टेक्स्ट है जिसे क्लिक किया जा सकता है। जब यूज़र इस टेक्स्ट पर क्लिक करेगा, तो वह "example.com" वेबसाइट पर पहुंच जाएगा। href attribute के बिना लिंक काम नहीं करेगा।

    2. src Attribute 

    HTML में <img> tag का उपयोग webpage में image जोड़ने के लिए किया जाता है। इस tag में src attribute का उपयोग image के path (address) को बताने के लिए किया जाता है। यह path उस image का location होता है जिसे webpage पर दिखाना है। src attribute के अंदर image का URL या file का नाम डबल कोट्स ("") में लिखा जाता है।

     src Attribute का Syntax:

    <img src="image-path" alt="alternate-text">

    उदाहरण:

    External Image का उपयोग:

    <img src="https://example.com/image.jpg" alt="Example Image">

    इस कोड में image का URL

    https://example.com/image.jpg है, और यह webpage पर दिखाई देगा। अगर image लोड नहीं हो पाती, तो "Example Image" alternate text के रूप में दिखेगा।

    Local Image का उपयोग:

    <img src="images/photo.jpg" alt="Local Photo">

    इस उदाहरण में images/photo.jpg उस image का path है जो आपकी local directory में मौजूद है।

    src attribute के बिना <img> tag image को लोड नहीं कर सकता। यह attribute image के स्रोत (source) को बताने का सबसे महत्वपूर्ण हिस्सा है।


    3. Width and Height Attributes


    HTML में <img> tag के साथ width और height attributes का उपयोग image के आकार (size) को निर्धारित करने के लिए किया जाता है। इन attributes के माध्यम से हम image की चौड़ाई (width) और ऊंचाई (height) को pixels में सेट कर सकते हैं। यह image को webpage पर सही आकार में दिखाने में मदद करता है।

    Syntax:

    <img src="image-path" width="value" height="value" alt="text">

    उदाहरण:

    Width और Height के साथ Image:

    <img src="https://example.com/image.jpg" width="300" height="200" alt="Example Image">

    इस कोड में image की चौड़ाई 300 pixels और ऊंचाई 200 pixels निर्धारित की गई है।

    सिर्फ Width सेट करना:

    <img src="images/photo.jpg" width="400" alt="Local Photo">

    यहां image की चौड़ाई 400 pixels होगी, और ऊंचाई स्वतः (auto) उसी अनुपात में adjust होगी।

    Note:

    width और height का उपयोग करने से image की default size को control किया जा सकता है।

    हमेशा सही अनुपात (aspect ratio) बनाए रखने की कोशिश करें ताकि image distorted न दिखे।


    4. alt Attribute 

    HTML में <img> tag के साथ alt attribute का उपयोग image के लिए वैकल्पिक (alternative) टेक्स्ट प्रदान करने के लिए किया जाता है। अगर किसी कारणवश image वेबसाइट पर लोड नहीं हो पाती (जैसे slow internet connection या file not found), तो यह टेक्स्ट यूज़र को दिखाया जाता है। इसके अलावा, यह attribute screen readers के लिए उपयोगी है, जिससे visually impaired लोग image की जानकारी प्राप्त कर सकते हैं।

    Syntax:

    <img src="image-path" alt="alternative-text">

    उदाहरण:

    Image के साथ alt Attribute:

    <img src="https://example.com/image.jpg" alt="A beautiful sunset over the mountains">

    अगर image लोड नहीं होती, तो "A beautiful sunset over the mountains" टेक्स्ट यूज़र को दिखेगा।

    Local Image के साथ:

    <img src="images/photo.jpg" alt="A family photo">

    यहां "A family photo" alt टेक्स्ट के रूप में दिखाई देगा, अगर image file उपलब्ध नहीं हो।

    Importance:

    Accessibility: यह visually impaired लोगों के लिए image का विवरण प्रदान करता है।

    SEO (Search Engine Optimization): Search engines alt attribute का उपयोग image content को समझने और indexing करने के लिए करते हैं।

    Fallback: Image न लोड होने पर यह यूज़र को जानकारी प्रदान करता है।

    alt attribute का उपयोग सही और सटीक image description देने के लिए हमेशा किया जाना चाहिए।

    5. style Attribute 

    HTML में style attribute का उपयोग किसी element की styling (जैसे font, size, color, background आदि) को directly define करने के लिए किया जाता है। यह attribute inline CSS प्रदान करता है, जिससे आप किसी specific element के लिए styling सेट कर सकते हैं।

    Syntax:

    <element style="property: value;">

    उदाहरण:

    Text का Color बदलना:

    <p style="color: blue;">यह टेक्स्ट नीले रंग में दिखेगा।</p>

    Font Size और Background Color सेट करना:

    <h1 style="font-size: 24px; background-color: yellow;">यह हेडिंग का आकार बड़ा और बैकग्राउंड पीला है।</h1>

    Border और Padding जोड़ना:

    <div style="border: 2px solid black; padding: 10px;">यह बॉक्स में टेक्स्ट है।</div>

    Importance:

    style attribute का उपयोग छोटे और specific styling के लिए किया जाता है।

    हालांकि, बड़े और जटिल डिज़ाइन के लिए external CSS या internal CSS का उपयोग बेहतर होता है।

    यह attribute आपको HTML और CSS को एक साथ जोड़ने की flexibility देता है, लेकिन कोड को clean और maintainable रखने के लिए इसे कम उपयोग करना चाहिए।

    6. lang Attribute

    HTML में lang attribute यह बताने के लिए उपयोग किया जाता है कि वेबपेज किस भाषा में लिखा गया है। यह attribute मुख्य रूप से <html> tag के अंदर उपयोग किया जाता है। यह attribute search engines और browsers को webpage की भाषा पहचानने में मदद करता है, जिससे accessibility और SEO (Search Engine Optimization) बेहतर हो जाता है।

    Syntax:

    <html lang="language-code">

    Language और Country Codes का उपयोग:

    lang attribute में पहले दो अक्षर भाषा को दर्शाते हैं (जैसे, en - English, hi - Hindi)।

    Language और Country Codes का उपयोग:

    lang attribute में पहले दो अक्षर भाषा को दर्शाते हैं (जैसे, en - English, hi - Hindi)।

    अगर देश को भी specify करना हो, तो आखिरी दो अक्षर देश को दर्शाते हैं (जैसे, en-US - English (United States), en-AU - English (Australia))।

    उदाहरण:

    English Language के लिए:

    <!DOCTYPE html>

    <html lang="en">

    <body>

    This webpage is in English.

    </body>

    </html>

    Hindi Language के लिए:

    <!DOCTYPE html>

    <html lang="hi">

    <body>

    यह वेबपेज हिंदी में है।

    </body>

    </html>

    English (Australia) Specify करना:

    <!DOCTYPE html>

    <html lang="en-AU">

    <body>

    This webpage is in Australian English.

    </body>

    </html>


    Importance:

    • Accessibility: Screen readers के लिए यह attribute उपयोगी है ताकि वे सही उच्चारण कर सकें।
    • SEO: Search engines को webpage की भाषा समझने में मदद मिलती है।
    • Multi-language Websites: अलग-अलग भाषाओं के लिए सही content दिखाने में मदद करता है।

    lang attribute का उपयोग हमेशा <html> tag में करना चाहिए ताकि browsers और search engines को webpage की भाषा स्पष्ट रूप से समझ में आ सके।

    7. title Attribute:

    HTML में title attribute का उपयोग किसी element के बारे में अतिरिक्त जानकारी (extra information) प्रदान करने के लिए किया जाता है। जब यूज़र अपने mouse pointer को उस element पर ले जाता है, तो यह जानकारी tooltip के रूप में दिखाई देती है। यह attribute लगभग सभी HTML elements के साथ उपयोग किया जा सकता है।

    Syntax:

    <element title="text">

    उदाहरण:

    Paragraph Tag के साथ:

    <p title="यह एक पैराग्राफ टैग है।">Title attribute का उदाहरण</p>

    जब आप इस पैराग्राफ पर mouse ले जाएंगे, तो "यह एक पैराग्राफ टैग है।" टेक्स्ट tooltip के रूप में दिखेगा।

    Link के साथ

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

    इस लिंक पर mouse ले जाने पर "Example Website" टेक्स्ट दिखाई देगा।

    Image के साथ:

    <img src="image.jpg" title="यह एक छवि है" alt="Image">

    जब आप image पर mouse ले जाएंगे, तो "यह एक छवि है" टेक्स्ट दिखाई देगा।

    Importance:

    Accessibility: यह उपयोगकर्ता को element के बारे में अतिरिक्त जानकारी देता है।

    User Experience: Tooltip के रूप में जानकारी प्रदर्शित करके उपयोगकर्ता के अनुभव को बेहतर बनाता है।

    title attribute का उपयोग सरल और प्रभावी है, लेकिन इसे तभी उपयोग करना चाहिए जब अतिरिक्त जानकारी की वास्तव में आवश्यकता हो।

    Tag और Attribute में difference 

    नीचे दिए गए उदाहरण से आप HTML Tag और Attribute का अंतर समझ सकते हैं।
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title>Tag और Attribute का उदाहरण</title>
    </head>
    <body>
        <!-- केवल Tag का उपयोग -->
        <h1>यह एक Heading Tag है</h1>
        <p>यह एक Paragraph Tag है।</p>

        <!-- Tag के साथ Attribute का उपयोग -->
        <a href="https://example.com" title="यह Example Website है">यह एक लिंक है</a>
        <img src="image.jpg" alt="यह एक छवि है" width="300" height="200">
    </body>
    </html>

    Tag का use (Structure)

    <h1>यह एक Heading Tag है</h1>
    <p>यह एक Paragraph Tag है।</p>
    ये tags content को structure प्रदान करते हैं।
    इसमें कोई additional properties नहीं हैं।

    Tag + Attribute का use (Functionalities):

    <a href="https://example.com" title="यह Example Website है">यह एक लिंक है</a>
    <img src="image.jpg" alt="यह एक छवि है" width="300" height="200">
    <a> tag में href और title attributes जोड़े गए हैं:
    href लिंक का address बताता है।
    title लिंक पर mouse hover करने पर tooltip दिखाता है।

    <img> tag में src, alt, width, और height attributes जोड़े गए हैं:
    src image का path बताता है।
    alt image का वैकल्पिक टेक्स्ट प्रदान करता है।
    width और height image का आकार सेट करते हैं।
    इस प्रकार, tags content का structure बनाते हैं, और attributes उन tags को additional functionalities देते हैं।


    Attributes case-insensitive का क्या मतलब है?

    Attributes case-insensitive का मतलब है कि HTML attributes के नाम uppercase (बड़े अक्षरों) या lowercase (छोटे अक्षरों) में लिखे जा सकते हैं, और यह दोनों ही तरीके से एक जैसे काम करते हैं। उदाहरण के लिए, HREF, href, और Href तीनों को ब्राउज़र एक ही तरीके से समझेगा।

    हालांकि, W3C की सिफारिश के अनुसार, HTML attributes को lowercase में लिखना सबसे अच्छा अभ्यास (best practice) माना जाता है। यह कोड को साफ-सुथरा और पढ़ने में आसान बनाता है। उदाहरण -- 

    <a href="https://example.com">Click Here</a>

    और

    <a HREF="https://example.com">Click Here</a>

    दोनों ही ब्राउज़र में एक जैसा काम करेंगे।

    HTML Attributes Kya Hai? Beginners ke liye Complete Guide

    HTML attributes किसी भी HTML element की अतिरिक्त जानकारी या विशेषताएं प्रदान करते हैं, जो उनके behavior और appearance को नियंत्रित करती हैं। 

    ये attributes webpage को अधिक functional और interactive बनाते हैं। चाहे वह link का destination हो, image का size, या text का color – attributes इन सभी को define करने में मदद करते हैं।

    इस गाइड में, आपने सीखा कि attributes कैसे HTML tags के साथ जोड़े जाते हैं, उनके मुख्य प्रकार क्या हैं (जैसे href, src, alt, style आदि), और उन्हें किस प्रकार effectively उपयोग किया जा सकता है। प्रत्येक attribute की सही understanding और उपयोग आपके webpages को अधिक professional और user-friendly बना सकता है।

    अंत में, HTML attributes को समझने और सही ढंग से implement करने से आप बेहतर डिज़ाइन और functionality वाले webpages बना पाएंगे। Practice करते रहें, और HTML के इस महत्वपूर्ण हिस्से में mastery हासिल करें।


    Read Also:

    HTML Kya Hai ? Main Elements of HTML in Hindi

    Best HTML Editors Website बनाने के लिए

    HTML Basic Guide for Beginners in Hindi

    HTML में Style Attribute का उपयोग कैसे करें 


    HTML Basic Guide for Beginners in Hindi

     

    HTML Basic Guide for Beginners in Hindi

    HTML Basic Guide (HyperText Markup Language) के बारे में

    HTML एक markup language है जो वेबपेज की structure को define करती है। इसे headings, paragraphs, images, और links जैसे elements के जरिए content को organize करने के लिए इस्तेमाल किया जाता है। HTML वेब डेवलपमेंट का पहला और सबसे जरूरी step है।

    HTML को सीखना आसान है क्योंकि इसमें tags और attributes का उपयोग होता है, जो साफ और logical होते हैं। उदाहरण के तौर पर, <p> tag का उपयोग paragraphs बनाने के लिए किया जाता है और <a> tag से hyperlinks जोड़े जाते हैं। सही HTML structure से आपकी वेबसाइट responsive और user-friendly बनती है।


    HTML Documents

    हर HTML डॉक्यूमेंट को document type declaration से शुरू करना जरूरी है:

    <!DOCTYPE html>

    यह ब्राउज़र को बताता है कि डॉक्यूमेंट HTML5 का है।


    HTML Document की संरचना:

    <html>: HTML डॉक्यूमेंट यहां से शुरू होता है।

    </html>: HTML डॉक्यूमेंट यहां खत्म होता है।

    दिखाई देने वाला हिस्सा:

    जो content यूजर को स्क्रीन पर दिखता है, वह <body> और </body> के बीच लिखा जाता है।

    <!DOCTYPE> 

    <!DOCTYPE> एक declaration है जो ब्राउज़र को बताता है कि HTML डॉक्यूमेंट किस version का है। यह वेबपेज को सही तरीके से दिखाने में मदद करता है।


    एक बार इस्तेमाल होता है:

    <!DOCTYPE> declaration को पूरे HTML पेज में सिर्फ एक बार इस्तेमाल किया जाता है।

    यह हमेशा HTML टैग्स से पहले आता है।


    Case Sensitive नहीं है:

    इसका मतलब है कि आप इसे uppercase (<!DOCTYPE>) या lowercase (<!doctype>) में लिख सकते हैं। दोनों valid हैं।

    HTML5 के लिए Declaration:

    HTML5 का doctype declaration सबसे simple और short है:


    <!DOCTYPE html>


    <!DOCTYPE> क्यों जरूरी है?

    Browser Rendering Mode:

    यह सुनिश्चित करता है कि ब्राउज़र सही rendering mode में काम करे।


    Standards Mode: ब्राउज़र HTML और CSS को पूरी तरह से web standards के हिसाब से दिखाता है।

    Quirks Mode: अगर doctype नहीं दिया गया तो ब्राउज़र पुराने नियमों के मुताबिक rendering कर सकता है, जिससे वेबसाइट का layout बिगड़ सकता है।


    Compatibility:

    यह आधुनिक HTML5 features और CSS के इस्तेमाल में मदद करता है।

    सभी पुराने और नए ब्राउज़र इसे support करते हैं।


    Example: HTML Document with <!DOCTYPE>


    <!DOCTYPE html>

    <html>

      <head>

        <title>DOCTYPE Example</title>

      </head>

      <body>

        <h1>यह HTML5 पेज है</h1>

        <p>यहाँ हमने <!DOCTYPE> का उपयोग किया है।</p>

      </body>

    </html>

    <!DOCTYPE html> ब्राउज़र को बताता है कि यह HTML5 डॉक्यूमेंट है।

    इसके बिना, पेज का structure और styling सही नहीं हो सकती।

    <!DOCTYPE> एक छोटा लेकिन जरूरी element है, जो ब्राउज़र को बताता है कि वेबपेज किस प्रकार का है। HTML5 में इसका उपयोग बेहद आसान और straightforward है, जो HTML coding को simple और efficient बनाता है।

    HTML Headings 

    HTML Headings क्या हैं?

    HTML में headings का उपयोग content को व्यवस्थित और structured तरीके से दिखाने के लिए किया जाता है।

    Headings को <h1> से <h6> टैग के जरिए define किया जाता है।

    <h1> सबसे महत्वपूर्ण और बड़ा heading होता है।

    <h6> सबसे कम महत्वपूर्ण और छोटा heading होता है।


    Headings का Structure

    HTML में headings को इस प्रकार लिखा जाता है:

    <h1>यह सबसे बड़ा और महत्वपूर्ण heading है</h1>

    <h2>यह दूसरे स्तर का heading है</h2>

    <h3>यह तीसरे स्तर का heading है</h3>

    <h4>यह चौथे स्तर का heading है</h4>

    <h5>यह पांचवें स्तर का heading है</h5>

    <h6>यह सबसे छोटा और कम महत्वपूर्ण heading


    Headings का उपयोग क्यों किया जाता है?

    Content का Structure:

    Headings text को hierarchy में प्रस्तुत करते हैं, जिससे content आसानी से समझने योग्य बनता है।

    SEO (Search Engine Optimization):

    Search engines (जैसे Google) headings को स्कैन करते हैं ताकि पेज के मुख्य विषय को समझ सकें।

    <h1> सबसे ज्यादा महत्वपूर्ण होता है और पेज के मुख्य विषय को दर्शाता है।

    Accessibility:

    Screen readers headings का उपयोग करके visually impaired users को पेज structure समझने में मदद करते हैं।

    Readable Layout:

    Headings content को visually appealing और पढ़ने में आसान बनाते हैं।


    Headings का उपयोग कैसे करें?

    <h1>:

    हर पेज पर केवल एक बार इस्तेमाल करें। यह पेज का मुख्य शीर्षक होना चाहिए।

    Example:

    <h1>वेबसाइट का मुख्य शीर्षक</h1>

    अन्य Headings (<h2> से <h6>):

    Subheadings के लिए इस्तेमाल करें।

    Example

    <h2>खाना पकाने के टिप्स</h2>

    <h3>शाकाहारी रेसिपी</h3>

    <h4>सूप और सलाद</h4>

    Example-

    <!DOCTYPE html>

    <html>

      <head>

        <title>HTML Headings Example</title>

      </head>

      <body>

        <h1>वेब डेवलपमेंट गाइड</h1>

        <h2>HTML Basics</h2>

        <h3>Headings का उपयोग</h3>

        <h4>SEO के लिए Headings</h4>

        <h5>Advanced Topics</h5>

        <h6>Footnotes</h6>

      </body>

    </html>


    Headings का Best Practice:

    1. Headings को content के महत्व के हिसाब से hierarchy में इस्तेमाल करें।
      • Example: <h1><h2><h3>
    2. Styling के लिए केवल headings का size बदलने के लिए <h1> या <h2> का गलत इस्तेमाल न करें। इसके लिए CSS का उपयोग करें।

    <style>

      h2 { font-size: 24px; }

    </style>


    अतः HTML headings content को structure और readability देने का एक महत्वपूर्ण तरीका हैं। <h1> से <h6> तक का उपयोग सही hierarchy में करने से वेबसाइट user-friendly और search engine-friendly बनती है।

    Hierarchy क्या है?

    Hierarchy का मतलब है किसी चीज को स्तर (levels) या क्रम (order) में व्यवस्थित करना। यह एक संरचना (structure) को दर्शाता है जिसमें उच्च (higher) स्तर से निम्न (lower) स्तर तक चीजों को व्यवस्थित किया जाता है।

    HTML Hierarchy:

    HTML में elements को एक tree-like structure में व्यवस्थित किया जाता है।

    Parent Element (मुख्य तत्व): सबसे ऊपरी स्तर का होता है।

    Child Element (उप तत्व): Parent के अंदर लिखा जाता है।

    Example:

    <html> <!-- Parent -->

      <head> <!-- Child -->

        <title>Hierarchy Example</title> <!-- Sub-child -->

      </head>

      <body> <!-- Child -->

        <h1>Heading</h1> <!-- Sub-child -->

        <p>Paragraph</p> <!-- Sub-child -->

      </body>

    </html>

    यहां <html> Parent है और इसके अंदर अन्य elements (जैसे <head> और <body>) Child के रूप में आते हैं।

    HTML Paragraphs 

    HTML में paragraphs का उपयोग text को व्यवस्थित तरीके से दिखाने के लिए किया जाता है।

    Paragraphs को <p> टैग के जरिए define किया जाता है।

    यह हर पैराग्राफ को अलग-अलग ब्लॉक में प्रस्तुत करता है।

    Syntax (लेखन शैली):

    <p>यह एक पैराग्राफ है।</p>

    <p>यह दूसरा पैराग्राफ है।</p>


    HTML Paragraphs की विशेषताएं:

    Automatic Line Break:

    <p> टैग का उपयोग करने पर text के बीच automatic space और line break आ जाता है।

    Readable Content:

    Paragraphs text को पढ़ने में आसान बनाते हैं और content को sections में विभाजित करते हैं।

    Inline Text Formatting के साथ इस्तेमाल:

    Paragraph के अंदर अन्य HTML टैग्स (जैसे <b>, <i>, <a>) का उपयोग कर text को format किया जा सकता है।

    Example:

    <!DOCTYPE html>

    <html>

      <head>

        <title>HTML Paragraph Example</title>

      </head>

      <body>

        <p>यह पहला पैराग्राफ है।</p>

        <p>यह दूसरा पैराग्राफ है जिसमें <b>मोटा टेक्स्ट</b> है।</p>

        <p>यह <i>इटैलिक टेक्स्ट</i> वाला पैराग्राफ है।</p>

      </body>

    </html>


    Output:

    • पहला पैराग्राफ: "यह पहला पैराग्राफ है।"
    • दूसरा पैराग्राफ: "यह दूसरा पैराग्राफ है जिसमें मोटा टेक्स्ट है।"
    • तीसरा पैराग्राफ: "यह इटैलिक टेक्स्ट वाला पैराग्राफ है।"

    Paragraphs का Best Practice:

    हर पैराग्राफ को <p> टैग में लिखें ताकि content अलग-अलग ब्लॉक्स में दिखे।

    Paragraphs को छोटा और clear रखें।

    Styling के लिए CSS का उपयोग करें, जैसे:

    <style>

      p {

        color: blue;

        font-size: 16px;

        line-height: 1.5;

      }

    </style>

    इस प्रकार HTML paragraphs (<p> टैग) text को structured और organized तरीके से दिखाने का सबसे आसान तरीका हैं। यह text को readability और clarity देने में मदद करता है। Proper styling के साथ इसका उपयोग आपके वेबपेज को अधिक आकर्षक और user-friendly बनाता है।

    HTML Links और Attributes

    HTML Links क्या हैं?

    HTML में Links का उपयोग किसी अन्य पेज, वेबसाइट, या resource (जैसे PDF, image, या वीडियो) पर नेविगेट करने के लिए किया जाता है।

    Links को <a> (anchor) टैग का उपयोग करके बनाया जाता है।

    Link की destination (जहां पर जाना है) को href attribute में define किया जाता है।

    Syntax (लेखन शैली):

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

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

    href (Hypertext REFerence): यह attribute link की destination URL को define करता है।

    Link Text: यह वह text है जिस पर user क्लिक करता है।

    Example (उदाहरण):

    <a href="https://www.webearningpoints.com/?m=1">यह एक लिंक है</a>

    Output:

    "यह एक लिंक है" पर क्लिक करने से user "https://www.webearningpoints.com/" वेबसाइट पर पहुंच जाएगा।

    Attributes क्या हैं?

    Attributes HTML elements को अतिरिक्त जानकारी प्रदान करते हैं।

    Attributes हमेशा opening tag में लिखे जाते हैं।

    Attribute में दो हिस्से होते हैं:

    1. Name (नाम): जैसे href, src, alt।

    2. Value (मूल्य): Attribute के लिए दी गई जानकारी।

    Example:

    <a href="https://www.example.com" target="_blank">Click Here</a>

    href: Link का destination (URL)।

    target="_blank": Link को नई tab में खोलने के लिए।

    Important Points:

    Link का Text:

    <a> टैग के अंदर का text clickable होता है।

    Example:


    HTML Links और Attributes 

    HTML Links क्या हैं?

    HTML में Links का उपयोग किसी अन्य पेज, वेबसाइट, या resource (जैसे PDF, image, या वीडियो) पर नेविगेट करने के लिए किया जाता है।


    Links को <a> (anchor) टैग का उपयोग करके बनाया जाता है।

    Link की destination (जहां पर जाना है) को href attribute में define किया जाता है।

    Syntax (लेखन शैली):

    html

    Copy code

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

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

    href (Hypertext REFerence): यह attribute link की destination URL को define करता है।

    Link Text: यह वह text है जिस पर user क्लिक करता है।

    Example (उदाहरण):

    html

    Copy code

    <a href="https://www.w3schools.com">यह एक लिंक है</a>

    Output:

    "यह एक लिंक है" पर क्लिक करने से user "https://www.w3schools.com" वेबसाइट पर पहुंच जाएगा।

    Attributes क्या हैं?

    Attributes HTML elements को अतिरिक्त जानकारी प्रदान करते हैं।


    Attributes हमेशा opening tag में लिखे जाते हैं।

    Attribute में दो हिस्से होते हैं:

    Name (नाम): जैसे href, src, alt।

    Value (मूल्य): Attribute के लिए दी गई जानकारी।

    Example:

    <a href="https://www.example.com" target="_blank">Click Here</a>

    href: Link का destination (URL)।

    target="_blank": Link को नई tab में खोलने के लिए।

    Important Points:

    1. Link का Text:

    <a> टैग के अंदर का text clickable होता है।

    Example:

    <a href="https://google.com">Google</a>

    Output: "Google" पर क्लिक करके user Google की वेबसाइट पर जाएगा।

    2. External और Internal Links:

    External Link: किसी अन्य वेबसाइट पर ले जाने वाला link।

    <a href="https://www.wikipedia.org">Wikipedia</a>

    Output: Wikipedia 

    Internal Link: उसी वेबसाइट के दूसरे पेज पर ले जाने वाला link।

    <a href="https://www.webearningpoints.com/2024/11/best-html-editors.html?m=1">best html editors</a>

    Output: best html editors 


    Attributes के बिना Link:

    अगर href attribute नहीं दिया गया, तो link काम नहीं करेगा।


    Example with Multiple Attributes:

    <a href="https://www.youtube.com" target="_blank" title="Visit YouTube">YouTube</a>

    href: Link की destination।

    target="_blank": Link को नई tab में खोलने के लिए।

    title: जब user link पर cursor ले जाएगा तो एक tooltip दिखेगा।

    Attributes के बारे में आगे सीखेंगे:

    Attributes HTML elements को ज्यादा flexible और informative बनाते हैं। आने वाले chapters में आप और attributes जैसे id, class, style, आदि के बारे में जानेंगे।

    अतः HTML Links (<a> टैग) वेबपेज को interactive बनाते हैं। href attribute link की दिशा तय करता है, और attributes links को additional functionality और styling प्रदान करते हैं। Proper attributes का उपयोग करके आप user experience को बेहतर बना सकते हैं।

    HTML Images और Attributes

    HTML Images क्या हैं?

    HTML में images को जोड़ने के लिए <img> टैग का उपयोग किया जाता है।

    <img> टैग self-closing है, यानी इसे बंद करने के लिए अलग से </img> की जरूरत नहीं होती।

    Images को web page पर दिखाने के लिए <img> टैग में विभिन्न attributes का उपयोग किया जाता है, जैसे src, alt, width, और height।

    Attributes और उनके उपयोग:

    1. src (Source):

    यह attribute image का source (फाइल का path या URL) बताता है।

    src में local image file (जैसे images/pic.jpg) या external URL (जैसे https://example.com/image.jpg) दिया जा सकता है।

    Example

    <img src="picture.jpg">


    2. alt (Alternative Text):

    यह attribute तब उपयोगी होता है जब image load न हो पाए।

    यह visually impaired users के लिए भी helpful है क्योंकि screen readers इसे पढ़ सकते हैं।

    Example:

    <img src="picture.jpg" alt="A beautiful sunset">


    3. width और height:

    ये attributes image के size को define करते हैं।

    इन्हें pixels या percentages में लिखा जा सकता है।

    Example:

    <img src="picture.jpg" alt="A beautiful sunset" width="500" height="300">


    Example:

    <!DOCTYPE html>

    <html>

      <head>

        <title>HTML Images Example</title>

      </head>

      <body>

        <h1>यह एक Image है:</h1>

        <img src="sunset.jpg" alt="Sunset on the beach" width="600" height="400">

      </body>

    </html>

    Output:

    यह कोड एक image दिखाएगा जिसका नाम sunset.jpg है, और अगर image load नहीं होती, तो "Sunset on the beach" लिखा दिखेगा

    Attributes के बिना Image:

    अगर आप केवल <img> टैग लिखते हैं और src या alt नहीं देते, तो image नहीं दिखाई देगी, या error आ सकता है।

    Example (गलत):

    <img>


    Image Optimization Tips:

    1. File Format का ध्यान रखें:

    JPEG: Photographs के लिए।

    PNG: Transparent background के लिए।

    SVG: Icons और graphics के लिए।

    2. Responsive Images:

    CSS का उपयोग करें ताकि image हर screen size पर अच्छी दिखे।

    Example:

    img {

      max-width: 100%;

      height: auto;

    }

    HTML Images (<img> टैग) web pages को आकर्षक और जानकारीपूर्ण बनाती हैं। src, alt, width, और height जैसे attributes के उपयोग से images को effectively manage किया जा सकता है। Proper attributes और optimization से user experience और SEO को बेहतर बनाया जा सकता है।

    HTML Basic Guide for Beginners 

    HTML सीखना किसी भी beginner के लिए आसान और उपयोगी है क्योंकि यह websites की foundation है। इस guide में हमने HTML के basic elements, जैसे headings, paragraphs, links, images, और attributes को समझा। HTML की structure को समझकर आप simple webpages बना सकते हैं।

    HTML सीखने के साथ-साथ इसे CSS और JavaScript के साथ integrate करना आपको interactive और आकर्षक websites बनाने में मदद करेगा। Practice करते रहें और concepts को implement करके अपनी skills को मजबूत बनाएं। HTML आपकी web development journey की पहली और सबसे महत्वपूर्ण सीढ़ी है

    Read Also 



    HTML Attributes Kya Hai? Beginners ke liye complete guide 

    HTML में Style Attribute का उपयोग कैसे करें