← Back to CSS
05

The Cascade in CSS: Origin, Order and Importance

Understand how the browser decides which rule wins when several styles target the same element.

📘 Theory

Style origins: browser, author and inline styles

Not all rules begin with the same priority.

Browsers apply default user-agent styles before your own CSS enters the picture. Your author styles usually override those defaults.

Within author styles, external files and internal `` blocks compete through source order. Inline styles start with greater weight in the normal cascade, and `!important` changes the priority even further.

  • User-agent styles are the browser defaults.
  • Author styles include external and internal CSS.
  • Inline styles live in the HTML `style` attribute.

Order of appearance

If everything else is equal, the later rule wins.

Importance and practical discipline

1

`!important` should stay exceptional. If you reach for it constantly, the structure of your CSS is probably fighting you.

2

Before using it, review your stylesheet order, your component architecture and whether the selector itself is the right one.

🧭 Key visuals

Cascade decision flow

Use it as a mental checklist when two rules compete for the same element.

Diagram showing how the CSS cascade evaluates importance, specificity and source order.

🧪 Learn by doing

Example Interactive demo: source order Switch the rule order and watch which color wins.

🏁 Challenges

Challenge Challenge: style origin Compare an author rule against an inline style.

🧰 Resources

Test

Check your knowledge with a test about CSS.

Test for CSS

What is this?

I'm Cristian Eslava and I sometimes build websites so both you and I can learn and experiment. culTest

I made this in February 2026 to make learning easier for my students. The idea is to learn web development by practicing and to keep expanding the project with new topics, tests and challenges.

It draws inspiration from MDN, W3Schools, CodePen, Manz and many other web development references. I wanted to combine useful theory, runnable examples, challenges and the testing system I had already built for culTest. culTest

If you liked it, if you didn't, or if you want to get in touch, write to me at cristianeslava@gmail.com