Is the order, or sequence, of rules in CSS significant?
This post says that it matters: Order of CSS rules matters!!!!!!!!!!
I haven't noticed anything about this in the CSS spec.
Should Calculating a selector's specificity say that if-and-only-if two rules have the same specificity, then it's the later of the two rules (i.e. whichever rule is defined after the previous rule) that's the effective rule?
Order does matter. If the specificity is equal, the rule declared later wins out. See Cascading Order in the spec:
...Finally, sort by order specified: if two declarations have the same weight, origin and specificity, the latter specified wins. Declarations in imported style sheets are considered to be before any declarations in the style sheet itself.
Your assumption is correct. A CSS rule defined later overrides a previous definition, unless the rule is less specific than the previous one.
To be more clear about the word "override": it adds to the previous style. If a later rule doesn't specify a specific style, the first one still remains valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With