ID, Name and Class | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

ID, Name and Class

what is the difference between ID, name and Class?

29th Oct 2017, 1:09 PM
A.J. Velasco
A.J. Velasco - avatar
3 Respostas
+ 6
'name' attribute is specific to form elements (<input>, <select>, and so on) and it's used to indentify date (as a key in a pair key/value) submited to server... however, in Html < 5 it's also an attribute of the <a> tag, but it's deprecated in Html5, and 'id' should be used instead: https://www.w3schools.com/tags/att_a_name.asp
29th Oct 2017, 1:21 PM
visph
visph - avatar
+ 3
id is used as unique identifier of an element. class is used for mutiple elements having that property. Name or other attribute is a property of an html tag.
29th Oct 2017, 1:14 PM
Claudiu Stefan Haidu
Claudiu Stefan Haidu - avatar
+ 2
Use aĀ classĀ when you want toĀ consistently style multiple elementsĀ throughout the page/site. in the Classes more than one element that shares the same style. Additionally, a given element can have more than one class associated with it, while an element can only have one id. For example, you can give a div two classes whose styles will both take effect. Use theĀ ID when you have aĀ single elementĀ on the page that will take the style. Remember that IDs must be unique. eg: -main-content, header, footer, or left-sidebar. * Each element can have only oneĀ id * Each page can have only one element with thatĀ id * You can use the sameĀ classĀ on multiple elements. * You can use multipleĀ classes on the same element.
29th Oct 2017, 1:26 PM
ElizabethšŸŒø
ElizabethšŸŒø - avatar