attributes

What are attributes 
किसी html element का उपयोग कैसे करते है? जाहिर है, उसके सरल रूप में। For example अगर आप किसी Web page में Image Add करते है, तो आप उसे इस तरह से लिखेंगे । परन्तु अगर आपको उस image की height, width, url, alt text etc. set करना हो तो आप क्या करेंगे।यहां पर काम आते है, html element के यह attributes . कुल मिलाकर अगर देखा जाए तो html attribute एक html element (tag) को extra configure या कहे उस element के बारे मेंadditional information provide करता है।

Syntax of HTML Attributes


attributes को हमेशा हम starting tag में define करते है और इस को हम name और value के pair में लिखते है।


   HTML में attributes definr करने का general syntax इस प्रकार है !



           <TagName Attribut="value">

                         some contant is here...

           </TagName>

       

  • name :- एक property है, जिसे आप set करना चाहते है। for example – image को extra configure करने के लिए src attribute का use किया जाता है। तो यहां पर image tag के attribute का name src है। जिसका उपयोग हम image को extra configure करने के लिए करेंगे।
  • value :- वह है, जो आप property के द्वारा उस element में Set करना चाहते है। value को हमेशा quotation (” “) के भीतर लिखा जाता है।

    Attributes के प्रकार - Types of attributes


    HTML Attributes को पढने की सुविधा के लिए चार श्रेणियों में विभाजित किया गया है. Attributes की इन चार श्रेणियों के बारे में नीचे बताया जा रहा है.
    1. Required Attributes
    2. Optional Attributes
    3. Standart Attributes
    4. Event Attributes
    Required and Optional Attributes :- Required और Optional Attributes लगभग एक जैसे ही होते है. इनका इस्तेमाल किसी विशेष HTML Element या कहें कि HTML Tag को Modify करने के लिये किया जाता है. आप चित्र वाले उदाहरण से इन्हें समझ सकते है. जिसमें src Attribute एक Required Attribute है और alt एक Optional Attribute है. 

    Standard Attribute :- Standard Attributes अधिकतर HTML Elements पर Apply होते है. इन्हें Global Attributes भी कहते है. आप Standard Attribute को Required एवं Optional Attributes के साथ-साथ ही इस्तेमाल कर सकते है.



    Scope of HTML Attributes 


    Attributes का scope उनके tags के according होता है। जिस tag के साथ आप जो attribute apply करते है उस attribute का effect उसी tag तक सिमित रहता है।
    उदाहरण के लिए आपने body tag में style attribute को यूज़ करते हुए text color red define किया है। Body tag पुरे page के लिए होता है इसलिए ये attribute पुरे page के text को red में show करेगा।
    यदि कोई sub tag वापस उसी HTML attribute को define करता है तो ऐसी situation में उसकी value parent tag में define किये गए attribute की value को override कर देगी।
    उदाहरण के लिए किसी paragraph tag का color green define करते है तो ये color body tag के color को override करेगा और आपका paragraph green text में show होगा। HTML में attributes के scope को निचे उदाहरण द्वारा बताया गया है।

     HTML Image का Syntax :-

    HTML Document में Image Insert करने का Syntax नीचे दिया जा रहा है.


    <img src = " img's Location " >


    EXAMPLE of Bosy Attributes:- 


    <html>
    <head>attribues</head>
    <body style="color:red">
    HTML learn in hindi <br>
    learn teachnical languge to easy way
    <p style="color:black" >
    this topic is ATTRIBUTES of HTML tages 
    </p>
    </body>
    </html>


                  



             OUTPUT :-









    Comments