
The Cascade
The magical waterfall of CSS
Imagine the cascade as a majestic waterfall flowing down the rocks of your stylesheet. On its way down, it touches every element, but not all get equally wet — or in this case, equally enchanted.
At the very top of the waterfall are the inline styles, like massive boulders splashing directly into the water. They hold the most power because they appear right at the element. Further down, in gentler waves, are the external stylesheets, which cast a subtle but ever-present magic. But when all else fails, the !important spell comes into play — the wildcard spell that ignores all other rules and does whatever it pleases, because sometimes, rules are meant to be broken! It’s the stubborn spell that insists on having its way, no matter how many other spells try to interfere.
The Cascade
Because selectors vie for dominance – and some are simply better at swimming.

Hierarchies
How the Cascade Works
The winding paths of the CSS cascade follow a secret hierarchy that determines which styles take precedence in an HTML document.
Rule Overwriting Within a Document:
Rules with greater specificity—meaning more precise selectors—have the final say, overriding less specific ones. If a conflict arises between equally specific rules, the one appearing later in the document wins.
CSS Rule Hierarchy (Lowest (1) to Highest Priority (5))
- Browser Defaults:
The dull, default styles the browser applies to all elements before your magic takes over. - Internal & External Stylesheets:
Rules in <style> tags in the head and external CSS files. The last included stylesheet has the final word.
- Within a Stylesheet:
Element Selectors:
Rules applied to all elements of the same type.
Class Selectors:
Rules giving a unified look to a group of elements.
ID Selectors:
Rules targeting a single, special element—the VIP section of CSS.
- Inline Styles:
CSS rules written directly within an HTML element’s style attribute. - !important Declarations:
When chaos ensues, the !important spell steps in, declaring itself the undisputed ruler. Use wisely, though, or chaos will reign!