I understand that in jQuery, it's advantageous to be more specific when using selectors so that jQuery doesn't have to traverse the entire DOM to find what you're looking for. For example, $('span.description')
is better than just $('.description')
if I know that the description
class is only ever applied to <span>
elements.
Is this the case with CSS, too? Is there any specific advantage for me to use span.description { }
instead of .description { }
? I'm thinking in terms of speed, optimization, etc. Am I saving the browser any work by telling it exactly where to look?