+ 2

What is the defference between "class" & "id" attributes in html ?

5th Apr 2017, 2:03 AM
Uppati Eeswar Rao
Uppati Eeswar Rao - avatar
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.
5th Apr 2017, 2:32 AM
Agus Mei
Agus Mei - avatar
+ 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.
5th Apr 2017, 2:08 AM
Luca Garrera
+ 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
13th Apr 2017, 4:26 AM
Sandeep Chatterjee