Equal specificity
Source order matters when selector weight and cascade level are equal.
Source order is the final tie-breaker. If two declarations have the same cascade level and specificity, the one written later wins.
.button--primary { background: #8cffc1; }
.button { background: #101827; }
/* Equal specificity? Later wins. */
Cascade & Control
Source order is simple, but only after you understand what it does not do. It does not beat higher specificity. It does not beat important declarations. It only decides when the competing declarations are otherwise equal.
This is why stylesheet order matters. A component rule loaded after a base rule can override it. A utility class loaded at the end can intentionally win.
Bad source order creates mystery. Good source order creates a readable path from base styles to components to overrides.
Source order matters when selector weight and cascade level are equal.
A stylesheet loaded later can override earlier CSS if the selectors tie.
Base styles should usually come before component styles.
Utility classes often live near the end so they can intentionally override.
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.
Set general defaults first.
Add page structure and spacing.
Style reusable UI pieces.
Add hover, focus, active and disabled behavior.
Small intentional overrides near the end.
Examples
/* 1. Base */
button { font: inherit; }
/* 2. Component */
.button { background: #101827; }
/* 3. Modifier */
.button--primary { background: #8cffc1; }
.button--primary { background: #8cffc1; }
.button { background: #101827; }
/* Primary buttons unexpectedly look default again. */
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.
Order only breaks ties after earlier cascade checks.
General styles should not unexpectedly override components.
Modifiers are meant to adjust the base component.
Throwing fixes at the end of a file creates hidden dependencies.
A predictable file structure makes source order easier to reason about.
Large files need clear order markers or cascade layers.
Production thinking
Source order is simple enough to seem harmless, but messy order creates long-term CSS debt. Good order lets developers predict where a rule should live.
If focus styles are defined early and later button rules override them, keyboard users can lose visible focus. Keep state styles in a reliable position.
Production CSS should have an intentional loading order. Base, layout, components, states and utilities should not be randomly mixed.
Stable source order supports stable rendering. A page that renders predictably is easier to test and maintain.
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
Source order is easy to understand but easy to abuse. A project should load reset, base, layout, components and utilities in an intentional order.
Put broad foundations before component details.
Component files should own component styling, not depend on random later overrides.
If utilities are allowed to override components, make that policy explicit.