Rolling the Dice with CSS Random()
Posted4 months agoActive4 months ago
webkit.orgTechstory
calmpositive
Debate
40/100
CSSRandomnessWeb Development
Key topics
CSS
Randomness
Web Development
The introduction of CSS random() function is discussed, with commenters exploring its potential uses, limitations, and implications for web development.
Snapshot generated from the HN discussion
Discussion Activity
Active discussionFirst comment
2d
Peak period
15
60-66h
Avg / period
6.2
Comment distribution31 data points
Loading chart...
Based on 31 loaded comments
Key moments
- 01Story posted
Aug 21, 2025 at 4:43 PM EDT
4 months ago
Step 01 - 02First comment
Aug 24, 2025 at 1:11 AM EDT
2d after posting
Step 02 - 03Peak activity
15 comments in 60-66h
Hottest window of the conversation
Step 03 - 04Latest activity
Aug 25, 2025 at 12:14 AM EDT
4 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
ID: 44977833Type: storyLast synced: 11/20/2025, 8:37:21 PM
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
Wonderful to see how CSS gets a usable random function before JS does.
The CSS function would be random(min, max)
Also the CSS function seems to take a number of steps, it is not immediately obvious to me how to do that with Math.random()
I imagine there's some deep ideological war over whether to add more programming functionality to css...
https://codepen.io/ArneSava/pen/BaWxOaR
Can we PLEASEPLEASEPLEASE have this secure by default from the beginning?
I would bet someone is already working on it as we speak.
Introducing cryptography in the STANDARD for stylesheets adds complexity where it doesn't belong. Ultimately a browser vendor isn't responsible when a company sells insecure cryptography.
Adding crypto to CSS will bring us nearer to bitcoin mining in the CSS engine.
Is there a way to get reproducibility? In the same browser or across browsers? Even if it's not the default mode.
WPT test results: https://wpt.fyi/results/css/css-values?label=master&label=ex...
Only Safari supports it for now, it seems.
https://www.sitepoint.com/the-cicada-principle-and-why-it-ma...
https://lea.verou.me/blog/2020/07/the-cicada-principle-revis...
In this case you would use multiple transparent tiles of different star patterns (images, or gradient/clip-path tricks), each one a different prime number in size. It should work with anything you can tile and overlay in CSS though.
The term for this is “low-discrepancy sequences”, there have been a handful of HN posts on it over the years. I know I’m bikeshedding the API already before it even really exists, but for image presentation I think a lot of applications might actually find that more useful.