Skip to content

CSS random() #1354

Open
Open

Description

@jsnkuhn

Description

The random() function is a math function that represents a random value between a minimum and maximum value, drawn from a uniform distribution, optionally limiting the possible values to a step between those limits

left: random(10%, 20%);
left: random(10%, 20%, 5%);

Specification

https://drafts.csswg.org/css-values-5/#random

web-feature

random-function

Test Links

https://wpt.fyi/results/?label=experimental&label=master&aligned&q=feature%3Arandom-function

Additional Signals

developer signal (16 votes)
web-platform-dx/developer-signals#514

caniuse:
https://caniuse.com/?search=random%28%29

mdn:
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/random

csswg:
https://github.com/w3c/csswg-drafts/issues?q=is%3Aissue%20state%3Aopen%20%22random()%22
still a few open issues. some specific to do with random() other about interaction with random-item(), @function

chrome:
https://issues.chromium.org/issues/413385732 (17 votes)

no Chrome platform status stats listing yet

Safari:
already in stable 26.2
https://webkit.org/blog/17640/webkit-features-for-safari-26-2/#css-calc-functions
https://webkit.org/blog/17285/rolling-the-dice-with-css-random/
already moving on to random-item()

Firefox:
https://bugzilla.mozilla.org/show_bug.cgi?id=1836588 (3 votes)
mozilla/standards-positions#809 (positive)

Firefox now has a nightly flagged implementation:
https://bugzilla.mozilla.org/show_bug.cgi?id=2071165

coding2GO: CSS Can Finally Be Random
https://www.youtube.com/watch?v=Uy3xsfAD8s0

polyfill:
https://www.npmjs.com/package/css-random-polyfill

Activity

  1. github-actions commented on Sep 3, 2026

    @github-actions

    This comment was automatically generated based on the information you provided. Please don't edit it.

    Below is additional information about the web feature (from the web-features project) which is referenced in your proposal.
    If this doesn't accurately correspond to your proposal, please update your initial comment to include web-features: <feature-id>.
    To find feature IDs, use the web-features explorer.

    Feature random()

    • ID: random-function
    • Name: random()
    • Description: The random() CSS function chooses a random numeric value within a specified range. This allows for dynamic, randomized styling using CSS.
    • Baseline status: Limited Availability
    • Docs: random() CSS function
    • Developer signals: 26 votes / 3 use cases (details)
    • WPT tests: wpt.fyi results
    • More information: See the web-features explorer
  2. bigandy commented on Sep 4, 2026

    @bigandy
  3. o-t-w commented on Sep 14, 2026

    @o-t-w
  4. jsnkuhn commented on Sep 16, 2026

    @jsnkuhn
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    focus-area-proposal

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions