I want to know which selector is the quickest for browsers and CSS

div.className or .className

also for these two

div#id or #id

2 answers

3
points

hints and tips here:

http://css-tricks.com/efficiently-rendering-css/

in order of speed:

#id
div#id
.classname
div.classname

if I've understood it correctly, but the differences will be hard to spot given that there are significantly slower inefficiencies inherent in the nature of the thing that you should endeavour to optimise first.

Answered over 8 years ago by Tony Crockford
1
point

Unless you'll be writing billions of styles for a single page it probably makes no difference whatsoever. Feel free to run a profiler on whatever rendering engine you're targeting if you disagree.

Answered over 8 years ago by Nathan Duran