CSS random() Lands in Chrome 156
Chrome 156 reached the stable channel on October 20, 2026, and it brings the CSS random() function with it. Generating a random value is now the browser's job rather than something bolted on from JavaScript. Safari got there first — the function has shipped since Safari 26.2 in December 2025, alongside sibling-index() and sibling-count().
The problem until now
Any design with mild variation — sticky notes tilted at different angles, dots scattered across a background, cards that don't look lined up with a ruler — needed one of three workarounds, each with a tax:
- Generate values at build time and inject them as inline styles: the HTML grows and the values freeze into one snapshot.
- Walk the elements in JavaScript and write properties: it lands after first paint and brings layout shift with it.
- Hand-write the values in the stylesheet: the whole thing dies the moment the element count changes.
What they share is that visual variation had no representation in the layer actually responsible for appearance.
What changed
random() takes a minimum and a maximum and returns a value between them of the same type — a length, an angle, a percentage, a number. An optional third argument sets a step, and an optional first argument, the <random-key>, decides who shares a value with whom:
.sticker {
rotate: random(--tilt element-scoped, -6deg, 6deg, 1deg);
translate: random(--x element-scoped, -10px, 10px)
random(--y element-scoped, -10px, 10px);
}
/* Fallback for browsers without support */
@supports not (rotate: random(0deg, 1deg)) {
.sticker { rotate: 0deg; translate: none; }
}Every .sticker gets its own tilt thanks to element-scoped, and because --x and --y are distinct keys, the horizontal offset doesn't mirror the vertical one. Without that control, the browser derives the seed from the property name and its position — and results end up correlated in ways you didn't plan.
The random-key is the part that matters
This argument is what separates a party trick from something you can rely on. Per the MDN reference:
auto(the default): an independent value for every element, property and position.element-scoped: each element gets its own value, but properties on that element share it — useful forwidthandheighttogether.property-scoped: all elements share one value per property.- A
<dashed-ident>such as--tilt: your own key, which makes two otherwise identical calls resolve differently. fixed <number>: a fixed seed, so the result becomes reproducible.
One practical warning: these key names changed during standardization. Older drafts use per-element and a by keyword before the step, so any older example you find online needs translating before you paste it.
Real-world caveats
Firefox hasn't shipped it. Support today is Safari 26.2 and later, plus Chrome and Edge 156. That makes @supports mandatory, not optional — and any design where the tilt carries meaning will break for part of your audience.
The value resolves once. The function is evaluated at style computation time; there is no reshuffle on interaction. If you need a new arrangement on every click, that is still JavaScript's job.
Custom properties behave two different ways. An unregistered custom property is substituted as text, so each var() use creates a fresh call with a fresh value. One registered through @property stores the computed value, so every use returns the same number. That difference is a reliable source of confusing bugs.
Accessibility before taste. A random value in color means unguaranteed contrast. Don't randomize layout, body copy, or touch targets. And under prefers-reduced-motion the right move is to flatten the angles, not to animate them.
Takeaway
random() won't change your architecture. It moves a responsibility that had been sitting in the wrong place: visual variation belongs to the style layer, and it now costs one line instead of a pass over the DOM. Start with decorative layers, guard them with @supports, and leave the core layout fixed.
Primary sources: the Chrome 156 release notes and the MDN reference for random(). If you're tracking how fast Chrome ships now, we covered that in Chrome Ships Every Two Weeks.