Firefox 161 supports the CSS function random() as of November 24, 2026. With it, the browser picks a random value between a minimum and a maximum, for example for width, rotation angle, or hue, without needing JavaScript.
According to the Chrome platform data, Chrome has supported the function since version 156. For Safari, MDN's compatibility data lists version 26.2, but MDN still does not list random() as Baseline, because the function does not yet work in all widely used browsers. Whether you use it in a client project therefore depends on how you handle fallbacks.
How does random() work in CSS?
The syntax is random(key, minimum, maximum, step), where key and step are optional. Minimum, maximum, and step must have the same data type, for example lengths, angles, times, or percentages. With random(0, 100, 10) you only get values in steps of ten, with random(0deg, 360deg) any rotation angle.
The key determines which values share a base value, as the MDN documentation describes. Without it, auto applies, and each call returns its own value. With element-scoped, each element gets its own value, which stays the same for all properties of that element. Width and height then result in squares of different sizes. With property-scoped, on the other hand, all elements share the same value per property: width and height differ, but all boxes look the same.
Which key shares which value?
According to the MDN documentation on random()
KeyEffect on the values
- no value (auto)Each call returns its own value
- element-scopedEach element has its own value
- property-scopedAll elements share one value
- --eigener-nameOne value across the whole document
With element-scoped, an element's width and height become equal in size.
Source: MDN Web Docs
A custom name like --streuung shares the value across the whole document, and fixed 0.5 sets the base value. With fixed, the value must be between 0 and 1, where 1 itself is not allowed.
What pitfalls are there?
One trap lies in the default value auto, because the browser generates the name for the base value from the property and position. If random(100px, 200px) is set as the width in both the normal state and the :hover state, both share the same value, and the width does not change when the mouse pointer is over it. MDN describes exactly this behavior.
According to the developer notes, Firefox 161 brings further new features. The functions var(), attr(), and env() now accept nested functions in the first parameter. In addition, Firefox supports the Compression Dictionary Transport technique: a server can mark a response as a dictionary and compress later responses against it, which can shrink script bundles that change little between versions.
What this means for you
Use random() at first for decoration, for example for scattered dots, varying rotation angles, or staggered animation starts. If the function fails there in an older browser, it harms no one.
- Check with an @supports query whether the browser knows random(), and otherwise serve fixed values. MDN queries order: random(1, 2) for this.
- Use element-scoped when each element needs its own value, and property-scoped when all elements should behave the same.
- Specify a step if the values should look tidy, for example random(0deg, 20deg, 5deg) for rotation angles in five-degree steps.
- Test states like :hover individually, because with the default auto nothing changes there.
- Check pages with random layout values at several window widths, because a randomly placed box can cover text.
The release notes do not mention regional restrictions; Firefox 161 is available for Windows, Mac, and Linux.
Mozilla released Firefox 161 on November 24, 2026.
Sources