I think the responses so far, taken together, serve to show that it's a
question of balance, although you certainly want to /favor/ classes over
lengthy selectors. In many cases you can do without ID or deeply nested
selectors entirely, but of course there are also plenty of times when
they're helpful and make the code more concise and elegant, for example
if you have section of a page that needs to override default styling and
the CSS would most likely never need to be reused.
And the point about first-child is a good one - first-child and
last-child are very handy.
Unfortunately I think this is one area where it's particularly difficult
to give a cut and dried answer - just remember that when thinking about
all the reusable "objects" (as in the first "O" of OOCSS) on your page
you should generally be thinking in terms of classes, not complicated
overrides or rules that assume a particular page layout/template.
On 6/25/12 3:56 PM, nicolechung wrote:
> them for CSS styling.
> I had a smallish site where I switched my ID's (for styling) over to
> CSS classes and it did make my stylesheet smaller and easier to
> maintain. And yes, my site did end up loading a lot faster just
> because I wasn't writing overly specific styles to override IDs.
> That being said, it would be a massive job on a bigger site to switch
> existing IDs over to classes, and there would be a lot of
> troubleshooting involved. Plus if you are working on a big site with a
> big team it would just be difficult to get so many people to adjust to
> not using IDs for CSS styling.
> As far as other selectors...I can't see getting rid of pseudo
> selectors for :hover effects and there are many cases where you say,
> need to style a first-child differently from the rest of your page.
> On Monday, 25 June 2012 15:05:26 UTC-4, lkrids wrote:
> I am a front-end developer and lately I have been reading a lot
> about css selectors performance and maintainable css. Together
> all the articles seem to suggest when possible use at least one
> class for each rule set, and the corollary that all dom nodes that
> receive css style should have at least one class. That means in
> css avoid ids, tags, descendant selectors, and basically all of
> these http://www.w3.org/TR/CSS2/selector.html#pattern-matching
> <http://www.w3.org/TR/CSS2/selector.html#pattern-matching>. Do
> you agree with this?
> You received this message because you are subscribed to the Google
> Groups "Object Oriented CSS" group.
> To view this discussion on the web visit
> To post to this group, send email to firstname.lastname@example.org.
> To unsubscribe from this group, send email to
> For more options, visit this group at