Skip to content
Web & searchmedium signalverifiedsupport checked August 31, 2026

A polyfill brings the CSS random() function to Chrome and Firefox

Lee Meyer published css-random-polyfill on CSS-Tricks on August 31, 2026. Only Safari implements CSS random() today, and it has since Safari 26.2 on December 12, 2025. The polyfill asks for a naming convention in exchange, and what you write stays valid CSS that keeps working once the script is removed.

By Redakcija WebAiRadarPublished 2 min readwritten by a modelUpdated
Image: CSS-Tricks

CSS random() returns a random value from a range you declare, with no JavaScript involved. So far you could only use it in Safari. On August 31, 2026, Lee Meyer published css-random-polyfill on CSS-Tricks, a script that runs the same declarations in Chrome and Firefox.

Where support actually stands

Checked against webstatus.dev on August 31, 2026, random() is implemented in Safari and Safari on iOS and nowhere else. It arrived in Safari 26.2, released on December 12, 2025, alongside sibling-index() and sibling-count(). Chrome, Edge and Firefox have nothing shipping in stable, and the Baseline status of the feature is limited.

Meyer writes that there are signs of work on it in both Chrome and Firefox, but no dates and no guarantee of a flag to try it behind. The specification itself is an editor's draft in what it calls an early exploration phase, with major breaking changes expected.

What the script asks for in return

The polyfill does not scan for the function wherever it appears. It works by convention: every random value goes into an intermediate custom property whose name starts with --random, and every element that should be processed carries a randomized class. That is what keeps the rest of the stylesheet valid CSS in a browser that has never heard of the function.

  • The optional third argument works, so random(1px, 7px, 1px) picks whole pixels only.
  • Keyed values work, so random(--side, 40px, 100px) hands the same result to two properties.
  • Units may be mixed as long as they resolve to the same data type, which is why random(2turn, 10turn, 20deg) is accepted.
  • Where the browser implements the function natively, the script processes nothing and steps out of the way.

The two limits worth knowing before you commit

The supported surface is narrower than the native one. The spec allows the function in place of any part of any property's value, the way calc() and min() work; the polyfill needs the detour through a custom property. Meyer calls this a compromise he can live with, because the declarations stay compatible with the native implementation and the script can be deleted later without touching the styles.

The second limit is a matter of timing. The script only processes computed styles that are applied to elements when the page first loads. One of the demos had to be reworked because of it: the random value was moved out of a keyframes animation and into a class applied at load time. Anything that changes after that is outside what the script covers.

„the polyfill is supporting a subset of what we will get with native random()“
Lee Meyer, CSS-Tricks

Sources

Once a week, in your inbox

The whole week's news, gathered into one email. No ads, no passing your address on, one-click unsubscribe.

The address is used only for this roundup. It is not sold and not passed to anyone.

Related

Google's illustration: a search bar reading "Personal Intelligence" with app icons arranged around it, the Drive and Wallet icons large and sharp, the Gmail, Photos, and Calendar icons small and faded.
Web & searchmedium signal

Google's AI Mode can now draw on your Google Wallet spending if you connect it

Google is letting people connect Google Wallet to AI Mode, the conversational side of its search, with Drive and the Gemini app to follow. The connections are off until you turn them on, and Google says AI Mode can only read the accounts. AI Overviews will also start reflecting your recent searches, which you can switch off.

Googleverified