The basics: the difference between a CSS id and class

Cascading Style Sheets

Cascading Style Sheets

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.

About Desi Reuben-Sealey

Desi is a UXC currently doing UX/UI Black Ops for applications, mobile and web, is a enthusiastic PADI scuba diver, a retired pro UK basketball player, Neo Soul music lover, an enthusiastic charity worker who likes to give to others is various ways.

Short URL:
QR Code:

Leave a Reply