Urgent.News

What's breaking now, across thousands of outlets.

Tech

Field Notes: Watching the Cascade Resolve, Start to Finish

Thursday's piece described the order the browser resolves conflicting CSS in: origin and importance first, then layer order, then specificity, then source order, with inheritance underneath all of it. Describing an order is one thing. Watching it actually run, on a real conflict, is another. This is that. Also available in Español The Setup One button. Six declarations, all fighting over the same…

This article examines the cascade resolution process for CSS, which determines the final style applied to an HTML element when multiple conflicting rules exist. The cascade order is as follows: origin and importance, layer order, specificity, source order, and finally inheritance.

In this example, six CSS declarations conflict over the color property of a button element. The order of operations is as follows:

1. Origin and importance: User-origin !important declarations take precedence over author-origin !important declarations. In this case, the button element's button { color: green !important; } declaration wins immediately.

2. Layer order: After removing the !important declarations, the layer order determines the winner. The unlayered #submit { color: red; } declaration beats every layered rule, regardless of their specificity or source order.

3. Source order: With the same layer and specificity, the source order comes into play. In this case, the .text-blue { color: blue; } declaration from the utilities layer wins over the .btn { color: navy; } declaration from the base layer.

Thus, the final color of the button element is green. The cascade process is a series of gates, each one only being consulted when the previous one fails to produce a decision. Most conflicts are resolved at the first gate, where origin and importance determine the winner.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

I Built a Kawaii Native GUI with Nim and SDL3

Native GUI demos often look like settings panels, administrative dashboards, or collections of standard controls. Those examples are useful, but they leave another question unanswered: can the same…

Notas de campo: la resolución de la cascada, de principio a fin

El artículo del jueves describió el orden en que el navegador resuelve los conflictos de CSS: primero origen e importancia, luego el orden de las capas, después la especificidad y, por último, el…

  • Origin and importance stage determines color: green wins due to user-origin !important
  • Layer order resolves remaining rules before specificity: unlayered red wins over layered blue
  • Source order decides between identical declarations: navy blue wins due to later appearance

Two great new repairable gadgets

Hi, friends! Welcome to Installer No. 141, your guide to the best and Verge-iest stuff in the world. (If you're new here, welcome, I'm newish here too, and also you can read all the old editions at…

More from Saturday 22 August →