+ 1
What is the difference between ID and CLASS?
Someone plz explain in details.
4 Answers
+ 7
ID should identify a single element with a unique label. Something that you have only one in the html code, like a menu bar.
CLASS can refer to a group of tags that share common properties. Example: table cell, or paragraph.
+ 5
id also has higher priority than class.
+ 2
Id must be unique
Class must not be unique
you can give the same class for many different tags
But you can't give the same id for many tags
0
id is used for specific element and class is used more than once id has more preference than class