In recent years, the rapid evolution of Cascading Style Sheets (CSS) has transformed modern web development. Features such as container queries, relational selectors like :has(), native nesting, and cascade layers have granted styling sheets powers that were once reserved exclusively for JavaScript. Front-end engineers can now eliminate dozens of lines of imperative script, replacing complex resize observers and DOM event listeners with a few declarative CSS rules.
However, a technical analysis by web developer Gabriel Shoyombo, published on Smashing Magazine, highlights a growing architectural challenge in modern front-end engineering: swapping JavaScript for native CSS features often creates an illusion of simplicity. While a pull request might show a satisfying net reduction in code lines, shifting operational logic into CSS can introduce hidden dependencies, silent layout shifts, and rendering performance bottlenecks across the wider application.
Shoyombo’s examination explores what happens when logic becomes fragmented between CSS and JavaScript, detailing how modern styling features interact with legacy codebases and browser rendering engines.
The Illusion of Simplicity: Local vs. System Complexity
The central thesis of Shoyombo’s investigation rests on the distinction between local simplicity and system complexity. Replacing a JavaScript script with a modern CSS declaration undeniably simplifies the specific file being edited. Yet, because CSS operates within a global ecosystem governed by the cascade, layout engines, and existing script listeners, a new feature acts less like an isolated function and more like a new occupant in a shared infrastructure.
This tension has sparked wide debate within the engineering community. Shoyombo points to an April 2026 essay by software engineer Igor Roztropiński, titled Modern Frontend Complexity: essential or accidental?, which questioned whether front-end development could return to simpler foundations given how drastically browser capabilities have expanded.
Public discussions surrounding the issue reveal a split among practitioners. On platforms like Reddit, some developers argue that modern minimalism often reduces capabilities rather than true complexity, claiming that many "less code" demonstrations simply perform fewer real-world tasks. Conversely, advocate developers contend that heavy front-end frameworks frequently introduce far more accidental complexity than they resolve, arguing that recent improvements in native CSS interactivity remain underutilized due to an over-reliance on JavaScript.
Shoyombo positions his analysis directly in the middle of this debate. He argues that native browser capabilities reduce overall complexity only when they completely replace existing functionality without disrupting the surrounding technical ecosystem. When modern CSS features interact unpredictably with remaining code, system complexity inevitably rises.
Scenario 1: Dual Ownership and Fragmented Logic
One of the most frequent friction points during codebase modernization occurs when control over a single UI component is accidentally divided between CSS and JavaScript.
In a traditional implementation, a component such as a media card might use a JavaScript ResizeObserver to listen to element dimensions and toggle a custom class, such as .card--wide. This class then applies multi-column grid layouts and larger font sizes through traditional CSS selectors.
When migrating to modern CSS, developers can declare container-type: inline-size on the parent container and wrap layout rules inside a @container query. This allows the layout to adapt natively without script intervention.
However, refactoring in large enterprise applications rarely occurs in a single atomic update. In practice, a pull request might introduce the @container rule for structural layout while leaving behind legacy script listeners registered in separate utility files, or leaving unremoved utility selectors targeting font sizes.
If both implementations initially share the same threshold—such as 480 pixels—the application appears to function correctly. But if a design requirement later adjusts the container query threshold to 600 pixels while leaving the legacy script untouched, the component enters a broken intermediate state between 480 and 600 pixels. In this zone, the component displays a single-column layout alongside a large-screen title.

Because the logic is split across two distinct systems, diagnosing the issue requires developers to inspect both script files and style sheets to trace how the buggy state was produced. Shoyombo emphasizes that while CSS and JavaScript can easily co-exist within the same component, they cannot safely share responsibility for the exact same UI behavior.
Scenario 2: Unexpected Layout Side Effects
Beyond fragmented logic, modern CSS features can trigger subtle rendering changes that extend far beyond their intended scope. Declaring container-type: inline-size does more than enable container queries for descendant elements; under the CSS specification, it also forces style and inline-size containment on the element and creates a new Block Formatting Context (BFC).
This dual behavior means a single line of CSS added for container querying can fundamentally alter three unrelated layout behaviors:
First, the creation of a new Block Formatting Context halts margin collapsing. In standard document flow, vertical margins between adjacent elements collapse into a single space. Once an element establishes a BFC, margins no longer collapse across its boundaries. A heading inside a query container will suddenly retain its full top margin, causing container heights to expand unexpectedly.
Second, block formatting contexts alter how elements interact with floated content. Under normal layout rules, text inside a standard block container wraps around preceding floated elements, while the block container’s background extends underneath the float. Once an element becomes a query container, the entire element box shifts to sit adjacent to the float, altering the component’s alignment and overall width.
Third, inline-size containment prevents an element from calculating its width based on its internal content. For standard block-level elements that inherit width from a parent container, this change may go unnoticed. However, if the query container is applied to flex items, inline-block elements, floated elements, or auto-grid tracks, the container collapses to a width of zero pixels, effectively causing components on the page to disappear entirely.
Shoyombo notes that these side effects highlight the danger of evaluating CSS properties in isolation without evaluating surrounding display modes and container constraints.
Scenario 3: Specificity Wars and Cascade Surprises
The introduction of powerful relational selectors like :has() and native CSS nesting provides engineers with expressive syntax, but it also increases the risk of unintended global side effects.
Because :has() evaluates descendant elements, an overly broad selector can inadvertently target elements deep within nested components. For example, a rule such as .card:has(img) p intended to remove paragraph margins on card components containing hero images will also match paragraphs inside nested child components, such as a user comment section that includes an avatar image. As a result, unrelated text blocks lose their padding simply because an image appeared inside a completely separate sub-component.
Similarly, native CSS nesting alters selector specificity in ways that can confuse engineering teams. Under CSS specifications, the nesting selector & inherits the highest specificity from its parent selector list, matching the behavior of the :is() pseudo-class.
If a combined rule set includes a high-specificity selector like an ID, all nested rules inherit that high specificity weight—even when targeting simple class elements. This can lead to situations where lower-level component utility styles fail to apply, prompting developers to write increasingly specific rules or rely on overrides, triggering a cascade battle across the stylesheet.
Furthermore, relying on modern Cascade Layers (@layer) can lead to unexpected behavior during partial migrations. While cascade layers are designed to manage specificity by prioritizing layered styles based on explicit order, unlayered legacy styles automatically take precedence over normal layered styles. If a engineering team places newly refactored CSS into @layer components while legacy global styles remain unlayered, the older legacy rules will consistently override the new CSS declarations regardless of how precisely the new selectors are authored.

Scenario 4: The Performance Myth and Rendering Engine Overhead
A common justification for replacing JavaScript with CSS is that native browser execution is inherently faster. Shoyombo’s benchmarks demonstrate that while CSS often delivers performance gains, moving logic to CSS does not automatically eliminate rendering overhead; it simply transfers the workload directly to the browser’s style calculation engine.
To evaluate the execution cost of relational selectors, Shoyombo conducted performance profiling in Google Chrome across a dataset of 5,000 DOM rows, testing how style recalculations behave when state changes occur.
In baseline testing, using JavaScript to toggle a simple class directly on an isolated element executed in under 0.1 milliseconds, forcing the browser to restyle only the single affected DOM node.
Applying a global :has() rule anchored high up in the document tree—such as body:has(.row.is-selected) .toolbar—increased style calculation time to approximately 1.4 milliseconds per toggle. While slightly slower than direct script manipulation, the recalculation cost remained small enough to easily fit within a standard 60Hz rendering frame (16.7 milliseconds).
However, performance degraded significantly when multiple :has() rules were present within the same stylesheet. Combining the global body-anchored selector with a secondary relational selector targeting internal list elements caused every single row state change to force a full style recalculation across all 5,001 DOM elements. This compound calculation pushed frame processing time to 7 milliseconds per toggle.
When the test scale was expanded to 20,000 rows, the compound CSS execution required 31 milliseconds per toggle—equivalent to dropping nearly two full rendering frames for a single visual update.
The testing illustrates that while individual modern CSS rules may appear performant, compound interactions between multiple complex selectors can trigger widespread DOM restyling that rivals or exceeds inefficient JavaScript operations.
The Greenfield Reality Gap and a Practical Path Forward
Shoyombo highlights that most educational guides and feature announcements demonstrate modern CSS capabilities from a "greenfield" perspective—assuming a clean, newly built application without legacy code. In enterprise software development, however, almost every deployment is a migration into an existing codebase filled with legacy patterns, unlayered stylesheets, and third-party scripts.
To prevent architectural decay during modern CSS migrations, Shoyombo proposes an evaluation checklist that development teams should complete before replacing JavaScript components:
- Verify Ownership: Ensure that responsibility for a specific UI behavior is fully transitioned to CSS, completely removing any corresponding JavaScript event listeners, resize observers, or class toggles.
- Audit Layout Mechanics: Check whether properties like
container-typealter the element’s block formatting context, affect float behaviors, or break collapsed margins and content-based sizing. - Scope Selectors: Constrain complex selectors using explicit child combinators to prevent relational rules like
:has()from leaking into nested child components. - Manage Specificity: Use pseudo-classes like
:where()to strip specificity weight from nested selector lists, ensuring styles remain easy to override when necessary. - Architect Cascade Layers: Avoid mixing layered and unlayered styles across the same component hierarchy to prevent legacy CSS from silently winning specificity conflicts.
- Profile Performance: Measure style recalculation times in browser developer tools under heavy data loads to ensure complex selectors do not trigger widespread DOM restyling.
Ultimately, modern CSS provides web developers with unprecedented power to create fluid, responsive user interfaces natively inside the browser. However, as Shoyombo’s analysis reveals, reducing line counts in individual files does not automatically equate to a simpler software system. Maintaining long-term codebase health requires engineers to evaluate new styling features not in isolation, but through their broader interactions with browser rendering engines, cascade architectures, and existing application logic.