Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do more specific css rules load better?

You can do this:

.info
{
    padding: 5px ;
}

Or, if you know it will be a div, you can do this

div.info
{
    padding: 5px ;
}

So, when there's a nested list.. you can do this..

div.info ul.navbar li.navitem a.sitelink
{
    color: #f00;
}

Or you can do this

a.sitelink
{
    color: #f00;
}

Readability aside, which is better for the browser to parse/run?

like image 600
bobobobo Avatar asked May 20 '10 19:05

bobobobo


People also ask

Which CSS rule has the most specificity?

Inline styles added to an element (e.g., style="font-weight: bold;" ) always overwrite any normal styles in author stylesheets, and therefore, can be thought of as having the highest specificity.

Does order of CSS rules matter?

CSS Order Matters In CSS, the order in which we specify our rules matters. If a rule from the same style sheet, with the same level of specificity exists, the rule that is declared last in the CSS document will be the one that is applied.

Which type of CSS has highest precedence?

Properties of CSS: Inline CSS has the highest priority, then comes Internal/Embedded followed by External CSS which has the least priority.

What is the order of the CSS specificity rule high to low?

Specificity Rules include:CSS style applied by referencing external stylesheet has lowest precedence and is overridden by Internal and inline CSS. Internal CSS is overridden by inline CSS. Inline CSS has highest priority and overrides all other selectors.


1 Answers

Keep rules as general as possible -- it is faster and uses less bytes. See Google's article for more info.

like image 185
Amy B Avatar answered Sep 27 '22 17:09

Amy B