I know others have been asking about using class and id in CSS files like
Div: Class vs Id
So, I know the semantic and syntactic differences between a class and id: this identifier should be used for elements that are used only once, and the class should be used for elements that share common attributes.
But this is not a strict rule, is it? What is the harm when using an identifier for multiple elements? Or use the class for just one? After all, this is not a “one element”, but just a collection (class) in which there is only one thing?
Will the browser CSS interpreter throw an error if I break the rules? I have not seen this.
So why do we have both id and class? Why not just call one or the other and call it good?
source
share