Skip to content

Repository files navigation

CSS Cascade

A visual explainer of the CSS Cascade, the algorithm that determines the "winning value" from a list of competing declarations.

Live site: cascade.arpit.codes

The seven cascade steps are laid out as a hand-drawn staircase diagram. Each step is a disclosure widget: click it to reveal the order of precedence within that step, or the rule that decides it.

  1. Origin and importance — transition, !important browser/user/author, animation, author, user, browser
  2. Context — shadow DOM and ::part()
  3. The style attribute — inline styles beat style rules
  4. Layers@layer ordering, and how !important reverses it
  5. Specificity — ID, class/attribute/pseudo-class, element/pseudo-element, then the zero-specificity selectors
  6. Scope proximity — fewest hops to the @scope root wins
  7. Order of appearance — last declaration in document order wins

Structure

File What's in it
index.html All content — the seven steps, the credits, and the inline SVG symbol sprite (arrow + caret)
style.css Everything visual, in cascade layers: reset, base, composition, blocks, utilities
script.js Progressive enhancement: wraps each step's <h2> in a <button> and turns the panel below it into a real disclosure widget
ShortStack-Regular-subset.woff2 Subset of the Short Stack typeface, preloaded

The page works without JavaScript. The panels are simply visible instead of collapsible. script.js only hides them once it has built the button that can bring them back, so a failed script can never leave content unreachable.

Running it

No build step, no dependencies. It's three files plus assets, served statically.

npx serve .

Opening index.html directly over file:// mostly works, but the .woff2 font and the ES module in script.js are happier over HTTP.

Deployment

Deployed on Netlify.No build command, no configuration file. Pushes to main deploy automatically.

Credits

About

A visual explainer of the CSS Cascade, the algorithm that determines the "winning value" from a list of competing declarations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages