I think it's useful to consider things beyond speed.

Unless your users can "really" tell the difference between the different
selector speeds, you might want to consider the overall readability and
maintainability.  I am a big believer in "striving" towards Semantic
Markup.  This means that lists of items are in UL/LI structures and H1
represents your main page title etc etc.  And your classes/ids/markup make
sense to someone who is new and working on the CSS.

I try to make my markup (and fail miserably all too often) without class or
ID.  When I need something, I ask myself, "Is this something that is totally
and uttery unique on the page.  If yes, *ID*, if its questionable, *class.*
And then I try to keep everything inside that node clean of id/class.

Example:
A global navigation and a local side navigation.  They couldd both be
<UL><LI> structures.  Let's say you use ID's for the two <UL> so you can
tell the difference.  Then your CSS could style them differently.  And you
can bind events that could walk the DOM tree the same way, despite the fact
that they are visually different.

Anyway, I'd sure I am not explaining this well enough, but I really hate
when half the css is based on classes and the other half based on IDs.  I
hate when half the jQuery is based on classes and the other half based on
IDs.

Again, if your users CAN tell the difference without a profiler, that is one
thing.  If they can't, then think about what is easiest to read and
maintain.

Please dont flame me everyone. :)

Glen

Reply via email to