Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

WebKit 9 min read How-to mediumAdept

Rolling the Dice with CSS random()

CSS is gaining a native `random()` function, now available in Safari Technology Preview, with the signature `random(min, max, step)` where all arguments share a unit type and the optional step rounds results. Because custom properties act like text substitution, reusing a random value needs a named ident (e.g. `random(--size, 1px, 7px)`) to share it across properties on one element, while `element-shared` shares a property's value across all matched elements, and the two can be combined. Demos include a star field, random grid placement, tossed photo stacks and a spinning wheel animation, all without JavaScript. The spec is still under CSS Working Group discussion and WebKit is asking developers for feedback.

Related posts

  • WebKit Features for Safari 26.5

    WebKit mediumAdept

    Safari 26.5 adds the CSS :open pseudo-class for styling open <details>, <dialog>, <select> and <input> pickers, an element-scoped keyword for CSS random() after the spec changed named random values to be global by default, color-interpolation="linearRGB" for SVG gradients, ToggleEvent.source for identifying a popover's invoker, and the Origin API for structured origin and same-site comparisons without the Public Suffix List. It also ships 63 bug fixes across anchor positioning, scroll-driven animations, block-in-inline layout, zoom rendering, SVG, WebRTC, IndexedDB and more. Code examples show how named random() values now behave and how to get per-element randomness back.

  • New to the web platform in August

    web.dev easyNovice

    Chrome 152 and Firefox 154 shipped to stable in August 2026, making several features Baseline Newly available: the text-box-trim/text-box-edge properties for trimming font leading, the sibling-count() and sibling-index() CSS functions, and the global autocorrect attribute. Chrome 152 also adds the CSS Color 5 alpha() function, the standardized window-drag property replacing app-region, OpaqueRange for range APIs over form-control text, and CSSPseudoElement support for ::backdrop, ::scroll-marker and ::view-transition. Firefox 154 adds Iterator helpers (includes, join, chunks, windows) and WebRTC transport APIs such as getSelectedCandidatePair(). The Chrome 153 and Firefox 155 betas preview single-axis scroll containers, Iterator zip, <camera>/<microphone> elements, and URL properties on SVG <a> elements.

  • Never too late for Firefox 88

    Mozilla Hacks mediumAdept

    Firefox 88 adds the CSS :user-valid and :user-invalid pseudo-classes, which apply form validity styling only after the user leaves a field. This avoids the jarring invalid state that :valid/:invalid show while someone is still typing. The release also ships CSS image-set() for resolution-dependent images in background-image, content and cursor, and makes outline follow border-radius while removing -moz-outline-radius. It adds RegExp match indices via the d flag and hasIndices, and disables FTP for security, with full removal planned for Firefox 90.

  • New to the web platform in June

    web.dev easyNovice

    Chrome 149, Chrome 150 and Firefox 152 reached stable in June 2026. The headline change is that `field-sizing` and the `rect()`/`xywh()` shapes in `shape-outside` are now Baseline across all major engines. Chrome also adds CSS `text-fit`, gap decorations for grid and flex, `background-clip: border-area`, Promise-returning scroll methods, the declarative `focusgroup` attribute, and bfcache eligibility for pages with open WebSockets. Firefox adds interim and final response-header timing in Resource Timing and notification action buttons, while the Firefox 153 and Safari 27 betas preview features such as `Error.stackTraceLimit`, `getAllRecords()`, transform-aware anchor positioning and the `:heading` pseudo-class.

  • New to the web platform in September

    web.dev easyNovice

    September 2026 brought Chrome 153 and 154, Firefox 155 through 157, and Safari 27 to stable, the first month of bi-weekly Chrome and Firefox releases. Many features reached Baseline Newly available: the CSS progress() and alpha() functions, the revert-rule keyword, image values in light-dark(), scroll anchoring via overflow-anchor, font-width, sizes="auto" for lazy images, async-iterable and transferable ReadableStreams, and cookieStore maxAge. Other additions include customizable <select> in Safari, <camera> and <microphone> elements, Iterator.zip and keyed Promise combinators, WebTransport updates in Firefox, and Service Worker static routing in Safari. Chrome 155 and 156 betas preview CSS random(), margin-trim, JPEG XL decoding, import defer and the <install> element.

The quest for software engineering knowledge.

Look:
Layout: