random()

Limited availability

The random() CSS function chooses a random numeric value within a specified range. This allows for dynamic, randomized styling using CSS.

Browser support

  • Chrome 156 Released on 2026-10-20
  • Chrome Android 156 Released on 2026-10-20
  • Edge 156 Released on 2026-10-22
  • Firefox 161 Released on 2026-11-24
  • Firefox for Android 161 Released on 2026-11-24
  • Safari Not supported
  • Safari on iOS Not supported

Baseline availability blocked since November 2026 by Safari (0 months)

Need this feature?
Leave a 👍 on the feedback issue
Don't forget to also leave a comment explaining your specific use case.

MDN documentation

Developer use cases

  • CSS random() is valuable for generating novel animations and layouts with a very low overhead. The broad trend in CSS for features such as this is obviating the need for JavaScript, especially when it comes to animations, is a very positive one. CSS random() is valuable for generating novel animations and layouts with a very low overhead. The broad trend in CSS for features such as this is obviating the need for JavaScript, especially when it comes to animations, is a very positive one. [see original comment]
  • For improving the visual design of web pages by making slight adjustments like choosing a random one to show, or transforming some elements to look more natural and less uniform. For improving the visual design of web pages by making slight adjustments like choosing a random one to show, or transforming some elements to look more natural and less uniform. [see original comment]
  • A zero-JS "slot machine" animation effect on my homepage at [lucascantor.com](https://lucascantor.com): a reel of facts about me spins and lands on a random one, and a dice button spins again. Radio inputs, `:has()` and `@keyframes` already do everything except the actual randomness. A zero-JS "slot machine" animation effect on my homepage at [lucascantor.com](https://lucascantor.com): a reel of facts about me spins and lands on a random one, and a dice button spins again. Radio inputs, `:has()` and `@keyframes` already do everything except the actual randomness. [see original comment]