Are html attributes specific to certain elements or they can be used for every element? In short, are they general or specific? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Are html attributes specific to certain elements or they can be used for every element? In short, are they general or specific?

my fellow coders, please explain it to me with examples. Thank you so much.

28th Jul 2018, 9:39 AM
Myussuf
9 Answers
+ 6
Good question. If you want a full list please check out this link: https://www.w3schools.com/tags/ref_attributes.asp The way it works is, many attributes share the same elements, but not all. Some elements have specfic attributes not shared by others, or share only a few of the same attributes. The list above though is comprehensive, so please do check it out. Cheers. 😊
28th Jul 2018, 10:23 AM
Tony
Tony - avatar
+ 6
Cheers! 😊
28th Jul 2018, 10:29 AM
Tony
Tony - avatar
+ 4
Depends. For eg class and id are used on almost every tags. But width and height attribute cant be used in form tags. Similarly src attribute is used only for script tag. Hope this helps ☺️☺️.
28th Jul 2018, 10:04 AM
Meet Mehta
Meet Mehta - avatar
+ 4
Yes.
28th Jul 2018, 10:26 AM
Meet Mehta
Meet Mehta - avatar
+ 2
In general, there are global (what you might be referring to when you say "general") attributes and non-global (for lack of a better term, or "specific" as you say) attributes. Global attributes are available for all elements while most elements also have their own special set of attributes that only work for that element (i.e. the "for" attribute for the "label" element) or might work across some elements but not others. You can find both lists at w3schools. https://www.w3schools.com/tags/ref_standardattributes.asp https://www.w3schools.com/tags/ref_attributes.asp The third category is custom attributes, which you can learn more about how to make them once you have a solid foundation in the attributes that are already supplied by the language.
29th Jul 2018, 12:33 AM
Janning⭐
Janning⭐ - avatar
+ 1
Thanks my friend. it means that some are general while others are specific to certain elements? thanks again my friend.
28th Jul 2018, 10:24 AM
Myussuf
+ 1
thank you so much MEET MEHTA and Anthony Quick
28th Jul 2018, 10:28 AM
Myussuf
0
thanks Janning⭐
29th Jul 2018, 4:56 AM
Myussuf
0
☺👍
29th Jul 2018, 5:57 AM
Janning⭐
Janning⭐ - avatar