Which CSS selector is faster in performance? Class in Class vs tagName in Class? -


note: question not have similar match on so.

i aware css selectors read right left. aware css class selectors should not additionally qualified tagname.

but among these faster (not talking specificity):

.group   div { ... .group .item { ... 

for html:

<div class="group">     <div class="item"></div> </div> 

since right left, doesn't mean in first case, browser search divs (and faster) compared second case, browser search every element has class of item (before comparing parent .group class)?

i expect .group .item (neglibibly) faster.

that's because, probably, number of div elements greater number of elements class item.

so if use .group div, every div match div part, , browser have ensure there .group ancestor. if use .group .item, every .item match .item part, , browser have ensure there .group ancestor.

for better performance, want avoid false positives, , if selector not going match element, want reject possible. .group .item should faster if there less .item div.

anyways, use child selectors instead of descendant ones if can. seems reasonable formers faster.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -