0Pricing
CSS Academy · Lesson

The Cascade: Origin and Order

Understand how stylesheet origin (user, author, browser) and source order determine cascade priority.

The Cascade: Origin and Order is a free CSS Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CSS Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What is the Cascade?

The cascade is the algorithm CSS uses to determine which style declaration wins when multiple rules target the same property on the same element. It considers origin, importance, specificity, and source order.

Cascade Origins

CSS declarations come from three origins, in priority order:

  1. User-agent stylesheet — browser defaults
  2. User stylesheet — custom styles set by users (accessibility)
  3. Author stylesheet — your CSS files

Cascade Origin Priority (Normal)

Under normal (non-important) declarations, author styles override user styles, which override user-agent styles. This is why your CSS beats browser defaults.

Cascade Origin Priority (!important)

Adding !important reverses the origin order for that declaration:

  1. User-agent !important
  2. User !important — highest priority (accessibility)
  3. Author !important

This is why user accessibility overrides (e.g., forced colors) cannot be defeated by author CSS.

After Origin: Specificity

When two declarations from the same origin compete, specificity determines the winner. Higher specificity wins — this is what developers think of first when debugging CSS.

After Specificity: Source Order

When two rules have identical specificity, the one that appears later in the stylesheet wins. This is the "source order" rule. It is why the order of your @import statements and @keyframe declarations matters.

@layer and Origin

CSS cascade layers (@layer) introduce a new cascade step between origin and specificity. Layer order determines priority, and a declaration in a later layer wins over one in an earlier layer regardless of their specificity.

The Full Cascade Priority

Complete priority order (highest to lowest):

  1. Origin + importance (!important user, !important author)
  2. Animation values
  3. CSS Layers (later layers win)
  4. Specificity
  5. Source order
  6. Transition values

Inheritance vs Cascade

Inheritance is different from the cascade. Inherited values come from the computed style of the parent element. They lose to any directly applied value, even from a low-specificity rule.

Using Source Order Intentionally

Place more specific (variant) styles after base styles in your stylesheet. This is why component files should be imported after reset and base files.

Cascade Debugging

In DevTools Styles panel, rules are listed from highest to lowest priority. Crossed-out rules lost the cascade. Hover over a rule to see its source file and line number for debugging.

Quick Check

Two rules target the same property with identical specificity. Which one wins?

Recap

The cascade resolves style conflicts using origin (author > user > browser), then importance (!important reverses order), then @layer order, then specificity, then source order. Understanding the cascade means you can predict exactly which rule wins any conflict — no more guessing.

Frequently asked questions

Is the “The Cascade: Origin and Order” lesson free?

Yes — the full text of “The Cascade: Origin and Order” is free to read here on the web, and the CSS Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CSS Academy course, upgrade to CoddyKit PRO.

What will I learn in “The Cascade: Origin and Order”?

Understand how stylesheet origin (user, author, browser) and source order determine cascade priority. You practise CSS Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start CSS Academy?

No prior experience is required. CSS Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “The Cascade: Origin and Order” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this CSS Academy lesson?

Yes. Every CSS Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Specificity Calculation: Inline Style ID Class Element
  2. The Cascade: Origin and Order
  3. !important: When and Why Not
  4. Inheritance and the all Property
← Back to CSS Academy