You find this answer everywhere on Google, why people just don’t look it up I don’t know (rant over).
Anyway, I get this question all the time: What’s the difference between “id” and “class” (If I had a pound for each time that question…)?
- id – a unique identifier, only
- class – this is a selector that can apply to many elements at once, or a sub-set of specific HTML elements.
In short add this to any element to which you want to give that extra garnish, but don’t add just the sake of it, always justify what you are doing; avoid code bloat.