Firefox 161 finishes cross-browser support for CSS random()
Firefox ships the random() function enabled by default today, matching Safari and Chrome. The JavaScript fallback for scattered or jittered values is no longer needed in any current browser.
Firefox 161 reached the release channel today, 24 November, enabling the CSS random() function by default. It returns a random value inside a property, between a minimum and maximum, with an optional step argument to limit results to fixed increments.
random() also takes an optional random-key as its first argument. Pass the same key, such as a custom --name, to several declarations and they share one random base value instead of each rolling independently, which is how you keep a rotation and a position in sync on the same element.
Safari added random() in 26.2, and Chrome shipped it in version 156 back in October. Firefox 161 is the last of the three engines to catch up, so the function now works without a JavaScript fallback in any current browser.
.card {
rotate: random(property-scoped, -4deg, 4deg);
top: random(0%, 100%);
}
Why it matters: scattering, jitter and varied delays have mostly needed a JavaScript generator or a pile of nth-child selectors faking randomness. With all three engines on board, that workaround can go, at least for anyone not supporting older or ESR releases.
The caveat: random() still is not formally Baseline, since that status needs time across all engines at current versions. Anyone supporting Firefox’s ESR line or older point releases still needs the JS fallback.