Skip to main content
CSS-Tricks
Since 2007
  • Articles
  • Guides
  • Almanac
  • Links
  • Picks
  • Newsletter
  • Search

Articles Tagged
random

5 Articles
{
,

}
Direct link to the article Quick Hit #135
CSS random safari

Quick Hit #135

Safari 26.5 updates random() in accordance with the CSS Values and Units Module Level 5 spec.…

Daniel Schwarz on May 13, 2026
A photo of rolling dice against a blue background,
Direct link to the article The Importance of Native Randomness in CSS
CSS functions random

The Importance of Native Randomness in CSS

We're getting new functions for generating random numbers in CSS! But the road to get here has been a long and winding one.
Alvaro Montoro on Apr 30, 2026
Direct link to the article random()
functions random

random()

The random() function in CSS is an experimental feature (i.e., not supported in any browser) that returns a random numeric value or random choice among multiple values from a range you specify. It works the same as JavaScript’s Math.random function…

Sunkanmi Fafowora on Oct 31, 2024
Direct link to the article Lots of Ways to Use Math.random() in JavaScript
JavaScript math random

Lots of Ways to Use Math.random() in JavaScript

Math.random() is an API in JavaScript. It is a function that gives you a random number. The number returned will be between 0 (inclusive, as in, it’s possible for an actual 0 to be returned) and 1 (exclusive, as in, …

Jwahir Sundai on Nov 30, 2020
Direct link to the article How To Generate a Random Color in JavaScript
color hex random

How To Generate a Random Color in JavaScript

Here’s a quicky (there is a PHP version too):

var randomColor = Math.floor(Math.random()*16777215).toString(16);

See the Pen
Generate New Random Hex Color with JavaScript
by Chris Coyier (@chriscoyier)
on CodePen.

If you’d prefer they are a bit more …

Chris Coyier on Dec 10, 2009

CSS-Tricks is powered by DigitalOcean.

Get Curated Front-End Roundups Right in Your Inbox

Coming back really, really soon! See past issues →

DigitalOcean
  • About DO
  • Cloudways
  • Legal stuff
  • Get free credit!
CSS-Tricks
  • Contact
  • Write for CSS-Tricks!
Social
  • RSS Feeds
  • CodePen
  • Mastodon
  • Bluesky
Back to Top