HTML Attributes


HTML Attributes क्या हैं?

HTML में Attributes का उपयोग किसी Element को Extra Information या Property देने के लिए किया जाता है।

👉 Attributes हमेशा Start Tag में लिखे जाते हैं और उनका Format इस तरह होता है:

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


HTML Attributes के मुख्य नियम

  1. Attributes हमेशा Start Tag में लिखे जाते हैं।

  2. Attributes का नाम और Value होता है → name="value"

  3. Attribute Values हमेशा Quotes " " में लिखी जाती हैं।

  4. एक Element में एक से ज्यादा Attributes हो सकते हैं।


Commonly Used HTML Attributes

  1. id – किसी Element को Unique पहचान देने के लिए।

    <p id="para1">यह पहला पैराग्राफ है।</p>
  2. class – एक से ज्यादा Elements को Same Style देने के लिए।

    <p class="red">यह टेक्स्ट Red Class में है।</p>
  3. style – Inline CSS लगाने के लिए।

    <h1 style="color:blue;">यह नीले रंग की Heading है।</h1>
  4. title – किसी Element पर Mouse Hover करने पर Tooltip दिखाने के लिए।

    <p title="यह Tooltip है">मुझ पर Hover करें।</p>
  5. href<a> Tag के साथ Link देने के लिए।

    <a href="https://www.ajcomputeredu.in">AJ Computer Education</a>
  6. src<img> या <script> के साथ File का Path देने के लिए।

    <img src="logo.png" alt="Logo">
  7. alt – Image न लोड होने पर Alternative Text दिखाने के लिए।

    <img src="ajlogo.png" alt="AJ Computer Education Logo">
  8. width / height – Image या Table के Size को Set करने के लिए।

    <img src="logo.png" width="200" height="100">


HTML Attribute Example

<!DOCTYPE html> <html> <head> <title>HTML Attributes Example</title> </head> <body> <h1 style="color:green;" title="Main Heading">यह एक Heading है</h1> <p id="para1" class="info">यह एक Paragraph है।</p> <a href="https://www.ajcomputeredu.in" target="_blank">हमारी Website देखें</a> <br> <img src="logo.png" alt="AJ Computer Education Logo" width="150"> </body> </html>

👉 इस Example में style, title, id, class, href, src, alt, और width Attributes का प्रयोग हुआ है।


HTML Attributes और Elements में अंतर

HTML ElementHTML Attribute
Element Structure बनाता हैAttribute Extra Information देता है
Example: <p>Content</p>Example: <p style="color:red;">Content</p>


Conclusion

HTML Attributes किसी भी Web Page को अधिक Powerful और Useful बनाते हैं।
👉 ये Elements को Extra जानकारी देकर उन्हें Customize करते हैं।
👉 Attributes का सही उपयोग SEO और User Experience दोनों के लिए जरूरी है।