Johanne Grenier2,111 Points
Div id VS class
What is the main difference between the id attribute and the class attribute in div elements?
I understand that the id names it, basically we are identifying it and naming it. I'm not sure what class stands for. I understand that it allows us to call them up in CSS. But wouldn't we be able to call them up using their id as well? And if so - when should we use which?
Callum KingFront End Web Development Techdegree Student 4,934 Points
In a HTML Document, you can only use the same ID on one element, but with classes you can give the same class to multiple elements.
Mandaar Dahale2,527 Points
The difference between an ID and a class is that an ID can be used to identify one element, whereas a class can be used to identify more than one. Like class div can be used to group elements together so that they can be easily targeted in css.
ID are more specific than class selector and it will override the element selector and class selector assigned to an element