HTML/CSSIntermediate#css#cascade

What is the CSS cascade and how is rule conflict order determined?

The cascade resolves conflicting rules using, in order: importance (!important beats normal), origin (author styles beat browser defaults), specificity, and finally source order (later rules win ties). Understanding this order prevents 'random' override bugs.

Example
.btn { color: blue; }
.btn { color: red; } /* wins: same specificity, comes later */
.btn { color: green !important; } /* wins over everything except another !important with higher specificity */

Related Questions

1
HTML/CSSIntermediate#css#cascade

What does !important do and why should it generally be avoided?

Open
2
HTML/CSSIntermediate#css#pseudo-elements

What is the CSS 'content' property used for with pseudo-elements?

Open
3
HTML/CSSBeginner#css#display

What is the difference between inline, inline-block, and block for form control styling?

Open