Specificity
Specificity uses a four-category system to give a CSS selector a value. The selector with the most specific value wins. Each
Specificity | High | Low | ||
---|---|---|---|---|
Selector | Inline | ID | Class, pseudo-class, attribute | element |
Weight | 1,0,0,0 | 0,1,0,0 | 0,0,1,0 | 0,0,0,1 |
Examples:
1 | nav#nav > li:hover { colour:red; } |
Selectors
These can help you add weight to the Specificity
1 | .myDiv { |
Universal and combinator selectors
These have no effect on specificity.
1 | // universal selector (*) matches elements of any type. |
pseudo-class
Common pseudo-class
selectors
1 | &:first-child { |
Attribute Selector
1 | .someClass[someAttribute] |