Diffrerence between id and class | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Diffrerence between id and class

I don't understand the differences of those ,are they the same ? And why?

8th Apr 2017, 6:36 PM
Gumza Dakalo
Gumza Dakalo - avatar
2 Answers
+ 11
Id and class attributes can both be used to reference an element, but there's a slight root difference between them: - id provide an html element identifier, supposedly been unique ( unique id for unique element ) - class provide an css style identifier, can be used on many html element class attribute ( and each class attribute can define many class names separated by a white space to be applied to an html element )
8th Apr 2017, 6:55 PM
visph
visph - avatar
+ 7
id is unique, whereas class can be used for different tags.
8th Apr 2017, 6:40 PM
Mario L.
Mario L. - avatar