CSS has historically been deterministic, forcing developers to rely on hacks, preprocessors, server-side languages, or JavaScript to achieve visual randomness. The new CSS Values and Units Level 5 specification introduces two native functions — `random()` and `random-item()` — that bring true randomness directly into the styling layer. This is significant not just as a feature, but as an architectural shift: it keeps layout decisions in CSS where they belong, follows the Rule of Least Power, and enables generative layouts and organic design patterns without delegating to JavaScript.

8m read timeFrom css-tricks.com
Post cover image
Table of contents
The Long and Winding Road to Random StylesA Web Problem, and a Web SolutionThe Big Deal
18 Comments

Sort: