HTML Attributes
HTML Attributes क्या हैं?
HTML में Attributes का उपयोग किसी Element को Extra Information या Property देने के लिए किया जाता है।
👉 Attributes हमेशा Start Tag में लिखे जाते हैं और उनका Format इस तरह होता है:
HTML Attributes के मुख्य नियम
-
Attributes हमेशा Start Tag में लिखे जाते हैं।
-
Attributes का नाम और Value होता है →
name="value"
-
Attribute Values हमेशा Quotes
" "
में लिखी जाती हैं। -
एक Element में एक से ज्यादा Attributes हो सकते हैं।
Commonly Used HTML Attributes
-
id – किसी Element को Unique पहचान देने के लिए।
-
class – एक से ज्यादा Elements को Same Style देने के लिए।
-
style – Inline CSS लगाने के लिए।
-
title – किसी Element पर Mouse Hover करने पर Tooltip दिखाने के लिए।
-
href –
<a>
Tag के साथ Link देने के लिए। -
src –
<img>
या<script>
के साथ File का Path देने के लिए। -
alt – Image न लोड होने पर Alternative Text दिखाने के लिए।
-
width / height – Image या Table के Size को Set करने के लिए।
HTML Attribute Example
👉 इस Example में style
, title
, id
, class
, href
, src
, alt
, और width
Attributes का प्रयोग हुआ है।
HTML Attributes और Elements में अंतर
HTML Element | HTML 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 दोनों के लिए जरूरी है।
No comments:
Post a Comment