
CSS Form Primitives That Replace JavaScript Helpers
Three small deletions: field-sizing for growing inputs, accent-color for control theming, and :user-invalid for polite validation styling — each with its own support gate.
TL;DR: Three small CSS capabilities each retire a helper that has been sitting in form code for years. field-sizing: content replaces the autosize script that measured scrollHeight. accent-color replaces hand-painted checkboxes and radios. :user-valid and :user-invalid replace the JavaScript that toggled validation classes at the right moment. They sit at three different support states, so each gets its own gate — and all three degrade to something functional, which makes them unusually cheap to adopt.
Death by a thousand helpers
Nobody decides to take on a form dependency stack. It accumulates. A designer asks for a textarea that grows as you type, so an autosize script arrives. The checkboxes need to match the brand color, so appearance: none goes on and a hand-drawn SVG replaces the native glyph, along with the focus ring, the disabled state, the indeterminate state, and the high-contrast handling that the native control had for free. Validation styling needs to appear at the right moment rather than on page load, so a small library starts writing .is-invalid onto fields.
Each of these is defensible on its own and none of them is architecturally interesting. Collectively they are a maintenance surface: three dependencies, three sets of edge cases, three things to re-test when the framework or the design system moves.
What they have in common is that each exists because one specific CSS capability was missing. The capabilities have arrived. Unlike the headline migrations in modern CSS, these deletions are low-ceremony — in each case here, one property or one pair of pseudo-classes replacing one dependency, with no architectural change to the component around it.
field-sizing: content — inputs that grow
The auto-growing textarea was the canonical example of a layout problem solved by measurement. The script listened for input, read scrollHeight, wrote a pixel height back, and repeated — a read-write cycle in the same frame, forcing synchronous layout, and getting stale whenever the font loaded late or the container resized.
textarea {
field-sizing: content;
min-height: 4lh;
max-height: 16lh;
}That is the whole replacement. The element sizes itself to its content and stops at the bounds you declare. The important authoring detail is that fixed width and height defeat the property — constrain with min-height, max-height, and the inline-size equivalents instead, and let the content drive what happens in between. When the content exceeds the maximum, the control scrolls, which is the same behavior a well-written autosize script would have produced.
It is not limited to textareas. Text inputs shrink-wrap their content and honor the placeholder for initial sizing, although fields the browser has autofilled keep a fixed size. Drop-down selects size to the selected option, and list-box selects grow tall enough to show all their rows. File inputs can size to the button and the displayed filename, but the HTML specification leaves applying the property to file inputs up to the browser. A text input with no minimum will render as narrow as the caret, so a min-width is effectively required rather than optional (MDN, accessed July 2026).
Two attribute interactions are worth knowing before you convert a component. The rows and cols attributes stop having an effect once the property is on, so a textarea that relied on rows for its resting height needs that expressed as a minimum in CSS instead. And maxlength caps growth as a side effect, since the control stops accepting the characters that would have made it taller — which is usually the behavior you want, but it means the visual bound and the input bound can come from two different places if you are not paying attention.
Support is the newest of the three: MDN records field-sizing as Baseline Newly available since June 2026 (accessed November 2026). Newly available means it works in current versions of all the core browsers, not that everyone is running current versions — verify against Baseline before deciding your gate, and expect the fallback to matter for a while yet.
accent-color and control theming
The second helper is the pile of custom checkbox styling that exists purely to change one color.
:root {
accent-color: var(--brand-600);
}One declaration themes checkboxes, radio buttons, range inputs, and progress elements while leaving the controls natively rendered — which means the focus indicator, the disabled treatment, the hover feedback, the platform's touch target sizing, and the forced-colors behavior all stay intact. The specification requires the browser to maintain contrast for legibility of the control against the accent you supply, and allows it to adjust the color's luminance or brightness, or substitute colors in other parts of the control, to do so. Not every browser does yet: as of November 2026, MDN's browser compatibility data records that Chrome for Android and several browsers built on it (Android WebView and Samsung Internet among them), as well as Safari on macOS and iOS and iOS web views from 15.4 through 26.1, do not maintain minimum contrast, so check a dark brand color on those browsers before relying on it.
The decision line is worth stating explicitly, because it is where teams over-invest. Use accent-color when native rendering is acceptable and only the color needs to change — a condition worth checking honestly against the design before choosing the custom path. Reach for appearance: none and full custom styling only when the design genuinely requires different geometry: a switch instead of a checkbox, a custom track, a non-standard indicator shape. Understand what that path re-owns: every state (hover, focus-visible, active, disabled, checked, indeterminate), every input modality, forced-colors mode, and the accessibility of whatever you drew. That is a component, not a style.
Support here is not Baseline: as of November 2026, web-features gives accent-color no Baseline status, because MDN's browser compatibility data records Chrome for Android's implementation as partial. caniuse records full support since Chrome and Edge 93 and Firefox 92, with Safari shipping partial support in 15.4 and completing it in 26.2, and still lists Chrome for Android as partial support — according to MDN's browser compatibility data, it does not maintain minimum contrast for the control. Counting partial support, that is roughly 97% of tracked global traffic (caniuse, accessed November 2026).
Validation-state styling that respects the user
The third helper is the one most people assume is a capability gap and is actually a timing gap. CSS has had :valid and :invalid for years — but they match from the moment the page renders. An empty required field is invalid before the user has done anything, so styling with them paints every form red on arrival. Timing is one reason validation libraries wrote classes: CSS could express the state, but not when to show it.
input:user-invalid {
border-color: var(--color-danger);
}
input:user-valid {
border-color: var(--color-success);
}:user-invalid matches only after the user has changed the control's value and committed that change, or has attempted to submit the form — not merely after focus has passed through the field. That is the polite timing the JavaScript was implementing (HTML Standard). It has been supported in all core browsers since November 2023 and reached Baseline Widely available in May 2026 (web-features, accessed November 2026). Once a field has been flagged, :user-invalid keeps matching while the value is still invalid, including while the user is correcting it, and :user-valid takes over as soon as the value satisfies its constraints.
Composed with the relational selector at the wrapper level — .field:has(:user-invalid) — the label and hint text follow the control's state without any class on the wrapper either; the relational-selector patterns have their own coverage.
The boundary is worth marking. These pseudo-classes style validation state. What the error message says, whether you validate on blur or on submit, how an error summary is built and focused, and whether constraint validation is the right mechanism at all are questions from the form-UX literature, and none of them are answered by a border color.
The per-primitive support table
The three primitives reached the core browsers at different times, and one of them is not Baseline at all as of November 2026, so they must not share a single support claim.
| Primitive | What it deletes | Support state (verified November 2026) | Behavior when unsupported |
|---|---|---|---|
| field-sizing: content | Autosize scripts measuring scrollHeight | Baseline Newly available since June 2026 (web-features) | Control keeps its default size and scrolls |
| accent-color | Hand-painted checkbox and radio styling | Not Baseline (web-features). ~97% of tracked traffic counting partial support; Chrome/Edge 93, Firefox 92, Safari 15.4 partial and 26.2 full, Chrome for Android partial (caniuse) | Control renders in the browser's default accent color |
| :user-valid / :user-invalid | Validation-state class toggling | Baseline Widely available since May 2026, Newly available since November 2023 (web-features) | Rule does not match; state simply is not colored |
Read the fallback column as the reason these are cheap. Every degradation is a working control: an un-grown textarea scrolls, an un-themed checkbox uses the browser's default accent color, an uncolored field is still validated by the browser and still blocks submission unless the form opts out with novalidate (or the submit button with formnovalidate). No user is locked out and no flow breaks — the interface is just less tailored on older engines. That is a materially different risk profile from a migration whose fallback is a broken layout, and it is why we generally advise adopting these one at a time as the design touches each control, rather than treating them as a project.