You speak:
In a css file, the last defined style takes precedence over the previous defined
Not so fast ... a higher specificity class takes precedence over the order in which classes appear in CSS! ( spec - Note how 'specificity appears before ' the order in which the list appears)
So, how would you calculate the specifics of the above classes?
From w3c spec :
Selectors within the pseudo-class of negation are counted like any other, but negation itself is not considered a pseudo-class.
So the specifics of the .red-with-not:not(.something) selector .red-with-not:not(.something) =
Where
a = # ID selector in the selector,
b = # class selectors, attribute selectors and pseudo-classes in the selector and
c = # type selector and pseudo-elements in the selector
Like other .red and .blue , which have specificity of only 010 (one class selector).
If you are interested, a
specificity calculator is a good reference for calculating specificity.
source share