Modern CSS Without JavaScript: A Practitioner's Guide

Modern CSS Without JavaScript: A Practitioner's Guide

Anchor positioning, CSS carousels, :has(), and native animation can now replace whole JS dependencies in browsers that support them. The support gate, degradation ladder, and migration frame for deleting them.

A cohort of CSS primitives that reached browsers between 2022 and 2026 — anchor positioning, CSS carousels, :has(), the customizable select, native entry and exit animation, exclusive accordions, and scroll-state queries — can now take over work that positioning, carousel, accordion, select, and animation libraries were installed to do, in the browsers that support each primitive. Deleting one of those dependencies is a per-component engineering decision with a repeatable three-step frame: check the support gate, design the degradation ladder, and run the migration to verified parity. This guide is the model and the decision frame; each primitive gets implementation depth in its own article.

What shipped: the 2026 CSS primitive cohort

For most of the web's history, interface behavior such as anchored overlays, carousel controls, and exclusive accordions meant JavaScript, either hand-rolled or pulled in as a dependency. Tooltips and dropdowns shipped a positioning library. Carousels shipped a slider library. Accordions, styled selects, and enter-leave animations each pulled in their own package or a few hundred lines of hand-rolled scripting. None of those dependencies existed because JavaScript was the right tool; they existed because CSS and HTML had gaps.

Between 2024 and 2026, an unusual number of those gaps closed at once. The features arrived separately, but they form a recognizable cohort: each one is an engine implementation of behavior that userland libraries had been approximating for years.

PrimitiveDependency class it replacesAdoption posture
Anchor positioningPositioning libraries (Floating UI, Popper) and hand-rolled tether mathAdopt with a fallback — the core (anchor-name, anchor(), position-area, @position-try) in all three engines since Firefox 147 joined Chrome 125 and Safari 26 in January 2026 (position-area from Chrome 129); web-features still rates the full feature Limited availability, implemented in full only by Safari 27
CSS carousels (::scroll-marker, ::scroll-button)Carousel and slider librariesEnhancement only — Chrome and Edge 135; not yet in Firefox or Safari
:has()Class-toggle plumbing and DOM observersAdopt — interoperable across all engines since late 2023
Customizable select (appearance: base-select)Select-replacement componentsEnhancement only — Chrome and Edge 135 and Safari 27, not yet in Firefox; the classic native select is the built-in fallback
@starting-style + allow-discreteMount/unmount animation orchestrationAdopt with a fallback — @starting-style and transition-behavior in all three engines since Firefox 129 joined Chrome 117 and Safari 17.5 (transition-behavior from Safari 17.4); animating display with allow-discrete only in Chrome and Edge 117+ and Safari 18+, not yet in Firefox
interpolate-size / calc-size()Measure-then-animate height scriptsEnhancement only — Chromium 129+; the 0fr grid technique is the cross-engine floor
Exclusive accordions (details name)Accordion componentsAdopt with a fallback — in all three engines since Firefox 130 joined Chrome 120 and Safari 17.2
scroll-state() queriesIntersectionObserver sentinels for stuck and snapped stateEnhancement only — Chrome and Edge 133+ for stuck and snapped queries (scrolled from 144); not yet in Firefox or Safari

Source: web-features 3.45.0 data and MDN browser-compat-data 8.1.8. Verified 2026-11. Support states move often, so re-verify at decision time rather than trusting any article, including this one.

The cohort's features are not all on the same track. Several have been focus areas of the Interop project, which tracks each engine's test pass rates for the areas it selects each year: :has() was a 2023 focus area, @starting-style and transition-behavior a 2024 one, and CSS anchor positioning has been one since 2025, with dialogs and popovers and scroll snap also among the 2026 focus areas. The carousel pseudo-elements, the customizable select, interpolate-size, and scroll-state queries are not Interop 2025 or 2026 focus areas, so their arrival in the remaining engines is not tracked as an Interop focus area. That matters for planning: features arrive on the engines' timeline, not your project's.

Why deleting a dependency is an engineering decision

The case for deletion is concrete, and it is worth stating precisely rather than as enthusiasm.

A UI dependency costs bundle weight on every page that renders the component, and positioning or carousel libraries can sit in the critical path of the most-visited pages. It costs upgrade and security churn: every dependency is a stream of version bumps, advisories, and occasional breaking changes that someone on the team absorbs. It costs accessibility variance — each library wires its own keyboard behavior and ARIA semantics, and migrating between libraries can introduce accessibility regressions. And it costs workarounds: z-index wars and portal helpers exist because overlays had to fight stacking contexts and ancestor clipping — a fight the platform's top layer now removes for elements rendered in it, such as popovers and modal dialogs.

The engine implementations reverse most of that. They ship no bytes. They are maintained by browser vendors. For a native element such as select, keyboard behavior is implemented by the browser following the HTML standard rather than reinterpreted by each library, though the standard notes that the particular keys can differ across implementations and platforms. Pinterest's migration shows the code-size side of this: its carousel rebuild on the new primitives replaced roughly 2,000 lines of JavaScript with roughly 200 lines of CSS — a 90% reduction, reported in Google's I/O 2025 recap (accessed October 2026).

The honest column is what the dependency still buys, because it is not nothing. A mature library behaves consistently on browsers the primitive has not reached. It embodies years of accumulated edge-case fixes — scroll containers, RTL, zoom, virtual keyboards — that an engine feature may or may not cover. And it usually does more than the primitive does: a select-replacement component that also filters and lazy-loads options is not fully replaced by a stylable native select.

That is why deletion is a per-component, per-dependency decision. Some libraries in your codebase deserve to go this year; some deserve to stay for several more. Treating either answer as doctrine is how teams ship broken fallbacks or, in the other direction, carry a positioning library for years after the platform could replace it.

The per-feature evaluation frame

Every article on this topic applies the same three-step frame to one primitive, and the frame is worth naming once.

First, the support gate: establish where the feature actually runs, from primary sources, dated. The answer determines everything downstream, and it is the most perishable fact in the whole decision.

Second, the degradation ladder: decide what browsers without the feature get. The only unacceptable answer is an accident. A carousel that degrades to a scrollable, swipeable track is a designed state; a dropdown that renders in the wrong corner of the viewport is not.

Third, the migration path: plan how the incumbent JavaScript is actually retired — parallel implementation, parity verification, then deletion. The library is removed at the end of the process, not the beginning.

Each step has a characteristic failure. Skipping the gate means adopting on enthusiasm and discovering the support reality in production. Skipping the ladder means shipping a broken experience to a browser cohort you forgot. Skipping the path means deleting the dependency before anyone verified that the replacement matches the behavior users depended on.

Reading browser support honestly

Support claims age badly, so this topic handles them with a small discipline: three named states, dated claims, and postures that follow the state.

A feature is in one of three real states. Interoperable and established: it works in all three engines and has for long enough that the remaining gap is old browser versions, not missing implementations — :has() is there. Newly interoperable: all three engines ship it, but recently enough that your traffic will include a meaningful share of browsers from before the arrival — the core of anchor positioning crossed this line in January 2026, when Firefox 147 followed Safari 26 and Chrome, although web-features still rates the full feature Limited availability. Single-engine: one engine ships it and the others have not — the carousel pseudo-elements, interpolate-size, and scroll-state queries are all here as of November 2026. The customizable select has just left this state: Safari 27 joined Chrome and Edge 135 in September 2026, and until Firefox ships it the single-engine posture still applies.

Each state maps to a posture. Interoperable and established: adopt, with at most a cascade-order fallback. Newly interoperable: adopt with a real fallback ladder, because the pre-arrival browser share is still material. Single-engine: adopt as enhancement only — the feature adds polish where it runs and must cost nothing where it does not — or wait, if the design cannot accept the degraded state.

The discipline is that the posture follows the feature's state, not your enthusiasm for it. Anchor positioning is a genuinely better model than JavaScript tether math, and it still spent more than a year in the enhancement-only tier while engines converged. The reverse discipline also applies: states change, and a gate written in 2025 may be obsolete by the time you read this. Date every claim, and re-verify before deciding.

How the work decomposes across this topic

This guide is the map; each area below is a separate implementation problem with its own article.

The two headline migrations are anchor positioning — the positioning layer that replaces Floating UI-class libraries, middleware by middleware — and CSS carousels, where scroll snap plus generated markers and buttons can replace the slider library outright in browsers that ship the markers and buttons, with scroll snap alone as the cross-browser floor. They are the deepest deletions and the best illustrations of the three-step frame.

Around them sit the rest of the cohort: the :has() patterns that retire class-toggle plumbing; the customizable select; the small form-styling primitives that each delete a helper script; entry and exit animation with @starting-style and allow-discrete; animating to intrinsic sizes with interpolate-size; native exclusive accordions on the details element; and scroll-state queries that replace sticky-detection sentinels. Two process pieces complete the set: the support-gate authoring craft — @supports and fallback-first code — and the dependency-deletion playbook that turns any of these migrations into a verified, reversible process.

Three boundaries keep this topic honest about what it is not. Organizational browser-support strategy — which Baseline threshold a company standardizes on, and how support policy is set and communicated — is a decision-maker discussion with its own literature; this topic assumes a policy exists and works within it. The composition of dialog, popover, and anchored overlays into full overlay patterns has its own dedicated coverage; where anchor positioning appears here, it is the geometry, not the overlay semantics. And scroll-driven motion — parallax, reveal effects, animation timelines — is motion UX with its own patterns and its own accessibility contract; scroll behavior appears within this topic only as component plumbing.

What CSS still does not solve

The cohort moves the boundary between markup and scripting; it does not remove it, and pretending otherwise produces a different kind of broken component.

Data-driven rendering stays in JavaScript. CSS can restyle a select, but something still populates its options from an API. It can animate a toast's entrance, but something still decides a toast is needed. State machines with more than a couple of states, state that persists or synchronizes with a server, and coordination across unrelated parts of the page all remain application logic.

Focus and keyboard behavior beyond what native elements provide also stays. The primitives are strongest exactly where they lean on elements that already carry semantics — details, select, dialog. Build a custom composite widget — an arrow-key menu, a typeahead, a roving tabindex — and you are back to scripting the focus model, whatever positions and animates it.

The practical rule: deleting the dependency does not delete the requirement. When a primitive covers most but not all of what a library did, the remainder must be consciously re-owned in a small amount of code or consciously descoped. The failure mode is assuming it vanished — that is how a migration that improved the bundle quietly dropped the keyboard behavior someone depended on.

Project Inquiry