- Firefox 161 was released on November 24, 2026, with support for the CSS random() function.
- Chrome shipped random() in version 156, and Safari was the first browser to ship it, in late 2025.
- random() returns a value between a minimum and a maximum, with an optional step and a key that controls which elements share a value.
Mozilla released Firefox 161 on November 24, 2026. The Firefox 161 release notes for developers list support for the CSS random() function, and Phoronix confirmed it in its coverage of the release. Chrome and Safari already had it, so the function now works in the current stable versions of all three major browser engines.
For anyone building backgrounds, this is the useful part: a little controlled variation, written in plain CSS. If a front end web development company like YuSMP Group looks after your site, random() is a good candidate for the next browser-support review, next to your existing fallbacks.
What shipped in Firefox 161?
Firefox 161 ships random() as described in the CSS Values and Units Level 5 spec. It generates a random value in a range, can snap that value to steps, and accepts an optional key that decides which random() calls share the same base value.
The same release adds two related CSS changes:
var(),attr()andenv()now accept nested functions in their first parameter, for exampleenv(var(--safe-area-block-start)).- Support for the CSS Typed Object Model, which exposes CSS values to JavaScript as typed objects instead of strings.
Where the other browsers stand
Firefox is the last of the three major engines to ship random():
- Safari was first. CSS-Tricks noted it shipped random() in late 2025.
- Chrome followed. The Chrome 156 release notes list the function with an example that scatters dots inside a container. Smashing Magazine covered it in October, when only Safari and Chrome had it.
- Firefox joins with version 161.
At the time of writing, MDN still marks random() as limited availability, since compatibility data usually updates after a release.
How does random() work?
random() takes two to four comma-separated arguments: an optional key, a minimum, a maximum and an optional step.
random(0, 100) /* any number from 0 to 100 */
random(0px, 60px, 15px) /* 0, 15, 30, 45 or 60px */
random(element-scoped, 0deg, 360deg) /* one value per element */
random(--hue, 180, 240) /* shared by every call using --hue */
Both bounds must be the same type. Two lengths work, and so do two angles. A length and a number will not. If you need mixed units, wrap each bound in calc().
Keys decide what repeats
The optional key controls which random() calls share a value:
auto(default): every call gets its own value, on every element and in every property.element-scoped: one value shared across properties on the same element.property-scoped: every element gets the same value for a given property.- A custom name such as
--hue: one value shared everywhere it appears. fixed 0.5: no randomness, the number you pass is used. This helps with screenshots and visual tests.
How can you use random() in backgrounds?
The most practical use is breaking up repetition. A row of cards that all use the same seamless texture looks stamped out. Shift each card's background by a random offset and the tile seams land in different places:
.card {
background: url(/textures/paper-1600.webp) 0 0 / 800px auto;
}
@supports (order: random(1, 2)) {
.card {
background-position: random(0px, 800px, 8px) random(0px, 600px, 8px);
}
}
Steps of 8px keep the offsets on your spacing grid. The 0 0 position in the first rule is the fallback for browsers that do not parse random().
Three more patterns that fit background work:
- Hue drift.
background-color: hsl(random(190, 230) 45% 22%);varies tone between tiles while lightness stays fixed, so text contrast stays predictable. - Scattered shapes. Random
rotate,topandlefton decorative dots or confetti, as in the Chrome example, without a build step that writes hundreds of static rules. - Twinkling light.
animation-delay: random(0s, 3s);on bokeh dots, so they pulse out of sync. Pair it with a backdrop like our 9 bokeh backgrounds set.
What fallbacks and guardrails do you need?
Treat random() as an enhancement. Keep a static value first, then put the random version in an @supports block. Visitors on older versions see the static design, which should still look finished.
- Contrast. Keep text-bearing backgrounds in a narrow range. Randomize hue or offset, not lightness. Our guide to readable text on backgrounds has the checks.
- Motion. Wrap random animation in
@media (prefers-reduced-motion: no-preference). - Testing. Values can differ between page loads, so pixel-diff tests will flag false changes. Swap in
fixedkeys in your test build. - Subtlety. Small ranges read as texture. Large ranges read as a bug. If you want visible grain instead, grain and noise is often the simpler tool.



