Urgent.News

600+ sources. One page. See who else covered it.

Editions

Tech

CSS Doesn't Need More Power — It Needs Better Boundaries

Also available in Español The Problem A team hits a styling problem that CSS won't cooperate with. Something needs to change based on a click, a scroll position, a piece of application state. So they reach for more power. A heavier selector. An !important . Sometimes CSS gets skipped entirely — element.style.display = 'none' , set directly from a click handler, because it felt more reliable than…

The CSS coding standard has been facing problems that cannot be solved by giving it more power. Instead, the focus should be on better defining boundaries. As CSS has its own inherent authority over presentation, transition, layout, and rendering, it should not be responsible for application state or business logic. The issue arises when CSS crosses the boundary into these areas, breaking the guarantee it already holds.

For example, toggling a panel's display property can be done either directly from a click handler or by using CSS to toggle a class. The second approach keeps presentation completely visible in the stylesheet, making it easier to understand without having to delve into JavaScript. This principle should be applied across the board, with CSS owning presentation, JavaScript managing behavior, and HTML handling structure.

By establishing these boundaries, the unpredictability, entropy, and reliance on JavaScript for presentation logic can be mitigated.

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

Read the original at dev.to →

More in Tech

El CSS no necesita más poder — necesita mejores límites

También disponible en English . El problema Un equipo se enfrenta a un problema de estilos con el que el CSS no coopera. Algo debe cambiar basándose en un clic, una posición de desplazamiento o un…

  • CSS requires clearer boundaries, not more power.
  • Overly heavy selectors, !important, and omitting CSS for JavaScript cause issues.
  • CSS already has four powers: presentation, transition, design, and rendering.