+ 2
What is the difference between class and id?
10 ответов
+ 6
class can be used many times but id can be used only once. Basically in HTML terms id is like head and class is like body. Hope you get my point.
+ 2
You can put the same class for many elements .
But, "Id" just for one element
+ 2
The class selector could be used on several elements but id selector is specific for a single element.
+ 2
id is unique whereas class is not , when you use class the properties will be applied on all elements that have the same class name, hope this help
+ 1
if your prooerty is repeated than use class or in other case use id
+ 1
id is unique whereas class is not. class can be used for multiple elements.
0
in addition id is used in javascripts
0
Id is used to target single element but class can be used to work on multiple elements
0
ID are unique whereas classes are not .one ID can be set to one element only wereas classes can be set for many elements .
USAGE : if u wanna style a single element , ID can be used . but if u want to style many elements by just writing few codes classes are handy .
0
the major difference is that IDs can only be applied once in a page while class can be used as many times in a page as needed