re: Reasons not to use IDs in CSS VIEW POST

VIEW FULL DISCUSSION
 

Where I use ID's in my CSS is if I want to support themes. This makes it easier to override colors and such.

 

That's a good idea - you can easily override existing class styles that way.

 

Where I work, we use IDs for CMS content where our front end devs used to use style scoped to attach styles to customisations on elements, in preference to making a bunch of inline styles.

We use them in styling only because they're sometimes the only hooks we have from third-party modules or legacy CMS systems. This means that the CSS has a bunch of IDs in it already, and when a new developer starts, they tend to continue using them. I think wherever we do anything from scratch we use classes for everything style-related and data attributes for everything script-related.

Personally I'd prefer to use type selectors and document hierarchy first and classes second, but my voice is very small and hard to hear!

code of conduct - report abuse