Origin
Browser defaults, user styles and author styles do not all have the same priority.
The cascade is the decision system behind CSS. It explains why one declaration wins, why another disappears and why adding more CSS is not always the fix.
.button { background: #101827; }
.button--primary { background: #8cffc1; }
.button { background: #62d5ff; }
Cascade & Control
CSS can receive declarations from several places: browser defaults, user settings, external stylesheets, internal CSS, inline styles and sometimes layers. The cascade decides which declaration controls the final value.
When two declarations target the same property on the same element, the browser does not guess. It compares importance, cascade layers, specificity and source order until one declaration wins.
If CSS ever feels random, it usually means you are missing one of those comparisons. Once you understand the cascade, CSS starts to feel much more logical.
Browser defaults, user styles and author styles do not all have the same priority.
!important changes the normal order and should be treated carefully.
More specific selectors can beat less specific selectors.
When everything else is equal, later CSS wins.
Visual model
The browser does not apply styles emotionally. It follows a priority system. These diagrams make that priority visible before you start changing declarations.
Where did the rule come from? Browser, user or author CSS?
Is the declaration normal or marked !important?
Does a cascade layer control priority?
How strongly does the selector target the element?
If everything ties, which declaration appears last?
Examples
.button {
background: #101827;
color: #f7f9ff;
}
.button--primary {
background: #8cffc1;
color: #061018;
}
.button { background: blue !important; }
.button.button.button { background: green; }
main section div .button { background: orange; }
.button { background: red !important; }
Rules that matter
CSS becomes easier when every override has a reason. If a rule wins by accident, the next developer has to debug your intention instead of the code.
Inspect the element and find which rule currently wins before adding more CSS.
The cascade decides per property, not per whole selector block.
If two selectors keep fighting, simplify the component structure.
Modifier classes are often cleaner than deep selectors.
It can solve one problem while creating the next one.
Some values are inherited even when no rule directly targets the child element.
Production thinking
The cascade is the reason CSS can be flexible and reusable. It also explains most beginner frustration. Learn it early and debugging becomes evidence instead of superstition.
A cascade mistake can hide focus states, reduce contrast or override readable text sizes. Inspect important accessibility styles before shipping.
Production CSS should have predictable layers of responsibility: base rules, layout rules, component rules, utilities and controlled overrides.
Search engines care about accessible content and user experience. Cascade mistakes that make content hard to read or interact with indirectly hurt performance.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If the answer is vague, inspect the lab example and trace which declaration wins.
Senior audit upgrade
When two declarations target the same property, the browser compares origin, importance, layers, specificity, scoping and source order. Source order only wins after the earlier factors are tied.
Browser, user and author styles are compared first, with important declarations treated separately.
Layer order can beat selector weight. Within the winning layer, specificity starts to matter.
Later only wins when the declarations are otherwise in the same cascade position.
origin -> importance -> layer -> specificity -> scope proximity -> source order