+ 2
What is the defference between "class" & "id" attributes in html ?
3 odpowiedzi
+ 18
ID's are unique
#Each element can have only one ID
#Each page can have only one element with that ID
Classes are NOT unique
.You can use the same class on multiple elements.
.You can use multiple classes on the same element.
+ 4
An ID identifies an element, since each ID should be assigned to only one element. Elements can only have one ID.
A class is a group of elements. One element can belong to multiple classes at the same time.
+ 4
both can be used for the other in case it is not causing problem.
. but id is to uniquely identify each elements, so each element must have different Id. for this reason we use it mostly in to identify elements.
and class is to define various elements with same role as one class.
see this discussion too
https://www.sololearn.com/discuss/101965/?ref=app