Optimize CSS: A narrow definition (#mytable tbody span.myclass) is better?

I wondered if the "narrow" definition, for example

#mytable tbody span.myclass
{
     color: #ffffff;
}

code>

better / faster to understand than just

.myclass
{
     color: #ffffff;
}

code>

I read somewhere that narrow definitions supposedly really have some effect on CSS speed, but I can’t remember where and for what time it was already, so I just wanted to clarify whether it matters or not, and if it happens which solution is better / faster.

Thank!

+1
source share
3 answers

Google Page Speed ​​provides some information on using effective CSS selectors . I suggest starting there.

So (very) basically, they recommend:

-, ,

, .

+2

- ; CSS, . , , , , , , , , .

, , , , .

+2

"Speed ​​optimization" really shouldn't bother CSS. The difference in any modern browser is extreme, but the difference in use is not. You have to decide when to use narrow or wide selectors based on what you want to achieve, how much you want cascading styles, where you want them to be applicable, and if you need to override a wider selector.

0
source

All Articles