Don't use IDs in selectors. Reasons for this warning?

4,132 views
Skip to first unread message

stenehall

unread,
Oct 16, 2011, 11:41:16 AM10/16/11
to CSS Lint
Hello.

Just found the css lint project and like the idea of it but found a
couple of warning strange.

What's the reasoning behind the "Don't use IDs in selectors." warning?
I can't see many cons for using ids as selectors but I can see a
couple of pros.

* An id shows more clearly what you're targeting.
* Not using ids might force you to stack multiple classes and hence
increase the css size.
* Even if the time might not differ much an id is at least not slower
than multiple classes/elements and the shorter selector the faster
from what I've learnt.

But given your warning you must have some reasons on the con side for
ids or in the pro side for classes?

Nicholas Zakas

unread,
Oct 17, 2011, 12:34:05 PM10/17/11
to css-...@googlegroups.com
Hi,

We've discussed this a lot. Oli has a nice writeup here:

-N
Reply all
Reply to author
Forward
0 new messages