Let’s Use the Emergent CSS random() Function in all the Browsers Safari became the first browser to support the CSS random() spec in late 2025, enabling randomized layouts without JavaScript, but half a year later there is no clarity on when it will land in other browsers. The feature allows controlled presentational randomness, with demos like Schalk Neethling's confetti effect and arguments from Alvaro Montoro that CSS is the most suitable language for such tasks. The creator of the TV show The Good Place wrote a tie-in book about moral philosophy https://en.wikipedia.org/wiki/How to Be Perfect which includes a chapter called “The Luck of the Draw,” discussing how the myth of meritocracy https://en.wikipedia.org/wiki/Myth of meritocracy leads people to “underestimate the role that luck has played in their lives.” Given how God seems to play dice with the universe https://archive.org/details/doesgodplaydicet00stew/mode/2up , there is something compelling in the way art imitates life https://hdsr.mitpress.mit.edu/pub/x5yq8vmk/release/1 when websites embrace controlled chaos in their designs https://www.smashingmagazine.com/2026/06/designing-uncertainty-how-ai-supercharges-probabilistic-thinking/ . The jury is out on whether extreme versions of this nondeterminism such as generative UI https://css-tricks.com/generative-ui-notes/ are a helpful usage of unpredictable UX. Indeed, when I see the YouTube comments reacting to Google’s upcoming usage of GenUI in search https://www.youtube.com/shorts/7l7U-6Qk0Jk , maybe it’s taking the idea too far down a bad path. But there is still something about the idea of a webpage that exists in a state of subtle flux each time you land on it, the same way you can’t step into the same river twice https://en.wikipedia.org/wiki/Heraclitus You cannot step into the same river twice . Real-world use cases for randomness I’m a consultant who often works on short-term, greenfield projects, which provide me with a window into the zeitgeist and the trends companies think are the future. It’s no coincidence that the idea of randomness permeated one of my recent projects. That’s epitomized by a burst of confetti to give the user a sense of excitement when they run a random draw https://www.plexus.co/random-draw-software they configured. And like many a UI feature in the corporate world, the simple idea of confetti was subject to several revisions to make every randomized particle align with the client’s brand. In fact, the requirements became custom enough that we ended up ditching the JavaScript plugin we were using and rolled our own confetti implementation This illustrates the tension between the conflicting needs for chaos and control in UX, even in a fun feature like random confetti. Wouldn’t it be nice if we could wield controlled presentational randomness in the presentation layer without leaving CSS? The CSS random function emerges If unpredictable user experiences are having a moment, it follows that CSS will do its part to make randomized layouts easy to implement. The creators of CSS have always been on a mission to harvest common UI patterns into declarative CSS standards https://youtu.be/EEJBJGNmzkI?si=Nd0WevnLo1c5fZ-D . In keeping with that spirit, we see that in late 2025, Safari became the first browser to support the CSS random spec https://webkit.org/blog/17640/webkit-features-for-safari-26-2/ css , as part of an update that emphasized “letting you solve common use cases with HTML and CSS alone, paving the cowpaths https://www.w3.org/TR/html-design-principles/ pave-the-cowpaths , and reducing the need for JavaScript or third-party frameworks.” Since then, cool demos and discussions of random keep popping up. For instance, Schalk Neethling showed us how CSS random can give us fine-grained control over the infamous confetti effect https://css-confetti.schalkneethling.com/ , and Alvaro Montoro made a strong argument https://css-tricks.com/the-importance-of-native-randomness-in-css/ that CSS turns out to be the most suitable language for such tasks. He points out this approach is in line with the Rule of Least Power https://www.w3.org/2001/tag/doc/leastPower.html , which encourages “solving a problem using the least powerful language capable of expressing and solving it.” Now the bad news: half a year after Safari introduced CSS random , there isn’t clarity on when it will land in the other browsers. At time of writing, there are signs of life that both Chrome https://issues.chromium.org/issues/413385732 and Firefox https://bugzilla.mozilla.org/show bug.cgi?id=1836588 a100336653 329583 have been working on it, but no guarantees about when we will be able to use it outside of the Apple world, even behind a browser flag. So, it seems currently I can only try the online demos of CSS random on my work MacBook and not on my PC where I do my personal projects. I am tempted to write my own implementation, but the syntax is surprisingly intricate https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/random , mostly because of elaborate random caching and keying semantics, combined with the options for base values and intervals. Even if I could manage to get all those details correct, CSS random is part of an editor’s draft spec https://drafts.csswg.org/css-values-5/ that’s in the “early exploration phase” and “major breaking changes are expected.” On top of that, from my dive into CSS polyfills in my article on ::nth-letter https://css-tricks.com/using-nonexistent-nth-letter-selector-now/ how-to-write-an-impossible-polyfill , we know the whole idea of a CSS polyfill can be a minefield. With all these obstacles in mind, a person would have to be a special breed of crazy to attempt to polyfill CSS random . Let’s polyfill CSS random One of the commenters on a neat YouTube demo https://youtu.be/Uy3xsfAD8s0?si=R8wzF6v5FS7mOLdU of the feature marvelled that it’s a “feature that works ONLY IN SAFARI? ? Did the Earth get flipped upside down?” Indeed, I am more accustomed to getting my first opportunity to experience emergent features in Chrome, which means my friends on iPhones often can’t run my experiments https://assets.publishing.service.gov.uk/media/667d2f0caec8650b100900c0/WP2 - The requirement for browsers operating on iOS devices to use Apple s WebKit browser engine 1.pdf . And yet, in the case of random , it’s darkly poetic that a feature based on chance appears in an unexpected place where many of us can’t use it. In fact, even Safari users may benefit from my css-random-polyfill package https://www.npmjs.com/package/css-random-polyfill , because Safari updates are tied to the OS https://support.apple.com/en-au/102665 , meaning not everyone can upgrade to the latest version of the browser. Besides, we know how much Apple loves it when you hack their stuff to improve compatibility https://www.youtube.com/watch?v=WXqVV8 GORE . Jokes aside, Apple seems serious about the “hackability” and transparency of everything about the open source WebKit engine that powers Safari https://opensource.apple.com/projects/webkit/ , and most of the demos I’ve used to test my polyfill are forks of demos from the WebKit blog, in which the Apple Safari team showed off the possibilities for CSS random back when it was in Safari preview https://webkit.org/blog/17285/rolling-the-dice-with-css-random/ . Demo: Random starfield Here’s my cross-browser version of the first demo from the Safari team’s article. It’s a randomly scattered field of stars fading in and out at random intervals. The larger, four-pointed stars all tilt at the same randomly selected angle. All stars have subtle, randomly hued shadows around them. To migrate the Safari-only original https://codepen.io/jdatapple/pen/YPyELeV to a version that works in Chrome and Firefox, we need to change the HTML to reference my polyfill script and add the randomized marker class to all elements that we want to polyfill. php < -- the script processes usages of css random on page load --