When an element's property's given more than one specified value, the following determines which rule to apply: in each 'section', the rule that comes from the highest numbered 'source' wins. If a tie, go onto the next section.
cascading-order section:
In the cascading order, if any one has !important
, it wins.
- user-agent stylesheet. (When it & rival(s) have
!important;
, it wins). - user. (When it & rival(s) have
!important;
, it wins over 3). - author
!important section:
If a rule has !important
it wins.
specificity section 1:
If a rule's from inline it wins.
specificity section 2: (when multiple selectors, the rule with the highest-numbered selector wins).
- type selector(
element
) &pseudo-element
. class
,pseudo-class
,attribute-selector
.id
selector.
specificity section 3:
The rule that has the highest number of the highest ranked selector wins.
source order section 1:
Between external & internal stylesheets, the stylesheet that appears lowest wins.
source order section 2:
The rule that appears lowest in the stylesheet wins.