When working with CSS, there’s the challenge of knowing what selector value will be placed on a element. Fortunately the W3 realized this and came up with a schema for browsers to follow in order to keep it standard amongst browsers and also something for coders to debug their code against. What’s best about it is that even though it’s not widely known, once you learn it, it will stick in your head forever (or at least when you need to use it).
For each selector you get a point value. Each point value starts out as 0.0.0.0 and grows as you process what is in each selector.
For every element in the select, you add 1 to the last column;
p,div {
color: #FB1;
} The value would be 0.0.0.2
For every class you have, you add 1 to the value of the third column;
div.cat {
color: #BCA;
} The value would be 0.0.1.1
For every ID element, you add 1 to the second column;
div#header li.nav {
color: #232;
} The value would be 0.1.1.2
And finally, if you use the style attribute in a tag, it adds 1 to the first column;
<div style="color: #424;">blah</div> The value would be 1.0.0.0
How it works is that CSS will go through and determine by specificity which rule will be applied to a property of an element. It’s essentially the higher the number, the more power it has. You should note that if one rule has a specifity of 1.0.0.0, it will rule over any other rule. Also a value of 0.1.0.1 would overrule 0.0.899.35 because it has a value in a higher level. Points are not transfered over, so there will never be a case where just classes will override something with an ID.
Remember, many professional and amature coders don’t know this or utilize it. Learn it and give yourself an edge in your debugging or general coding practices.