coderef

Numeric factory functionsLimited availability

The numeric factory functions, such as CSS.px() or CSS.kHz(), return a CSSUnitValue representing a CSS number value (as in 12px or 440kHz).

Not yet supported in all major browsers — check the table and provide a fallback.

Browser support

DesktopChrome
1–65Not supported
66+Supportedsince Apr 17, 2018
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
✕Not supportedup to 157
Current: 157
Safari
1–16.3Not supported
16.4+Supportedsince Mar 27, 2023
Current: 27
MobileChrome Android
18–65Not supported
66+Supportedsince Apr 17, 2018
Current: 155
Firefox Android
✕Not supportedup to 157
Current: 157
Safari iOS
1–16.3Not supported
16.4+Supportedsince Mar 27, 2023
Current: 27

How to use

Not supported in Firefox, Firefox Android. Use feature detection below and provide a fallback (or a polyfill) for those browsers.

Example

Full syntax and examples are on MDN: factory functions static.

Feature detection

JS · check before using
if ("CSS" in globalThis && "Hz" in CSS) {
  // CSS.Hz is available
}

Sub-features

Support for each part of the feature (63). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
CSS.Hz_static6679✕16.466✕16.4
CSS.Q_static6679✕16.466✕16.4
CSS.cap_static118118✕17.2118✕17.2
CSS.ch_static6679✕16.466✕16.4
CSS.cm_static6679✕16.466✕16.4
CSS.cqb_static105105✕16.4105✕16.4
CSS.cqh_static105105✕16.4105✕16.4
CSS.cqi_static105105✕16.4105✕16.4
CSS.cqmax_static105105✕16.4105✕16.4
CSS.cqmin_static105105✕16.4105✕16.4
CSS.cqw_static105105✕16.4105✕16.4
CSS.deg_static6679✕16.466✕16.4
CSS.dpcm_static6679✕16.466✕16.4
CSS.dpi_static6679✕16.466✕16.4
CSS.dppx_static6679✕16.466✕16.4
CSS.dvb_static108108✕16.4108✕16.4
CSS.dvh_static108108✕16.4108✕16.4
CSS.dvi_static108108✕16.4108✕16.4
CSS.dvmax_static108108✕16.4108✕16.4
CSS.dvmin_static108108✕16.4108✕16.4
Show 43 more
Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
CSS.dvw_static108108✕16.4108✕16.4
CSS.em_static6679✕16.466✕16.4
CSS.ex_static6679✕16.466✕16.4
CSS.fr_static6679✕16.466✕16.4
CSS.grad_static6679✕16.466✕16.4
CSS.ic_static118118✕16.4118✕16.4
CSS.in_static6679✕16.466✕16.4
CSS.kHz_static6679✕16.466✕16.4
CSS.lh_static118118✕16.4118✕16.4
CSS.lvb_static108108✕16.4108✕16.4
CSS.lvh_static108108✕16.4108✕16.4
CSS.lvi_static108108✕16.4108✕16.4
CSS.lvmax_static108108✕16.4108✕16.4
CSS.lvmin_static108108✕16.4108✕16.4
CSS.lvw_static108108✕16.4108✕16.4
CSS.mm_static6679✕16.466✕16.4
CSS.ms_static6679✕16.466✕16.4
CSS.number_static6679✕16.466✕16.4
CSS.pc_static6679✕16.466✕16.4
CSS.percent_static6679✕16.466✕16.4
CSS.pt_static6679✕16.466✕16.4
CSS.px_static6679✕16.466✕16.4
CSS.rad_static6679✕16.466✕16.4
CSS.rcap_static118118✕17.2118✕17.2
CSS.rch_static118118✕17.2118✕17.2
CSS.rem_static6679✕16.466✕16.4
CSS.rex_static118118✕17.2118✕17.2
CSS.ric_static118118✕17.2118✕17.2
CSS.rlh_static118118✕16.4118✕16.4
CSS.s_static6679✕16.466✕16.4
CSS.svb_static108108✕16.4108✕16.4
CSS.svh_static108108✕16.4108✕16.4
CSS.svi_static108108✕16.4108✕16.4
CSS.svmax_static108108✕16.4108✕16.4
CSS.svmin_static108108✕16.4108✕16.4
CSS.svw_static108108✕16.4108✕16.4
CSS.turn_static6679✕16.466✕16.4
CSS.vb_static108108✕16.4108✕16.4
CSS.vh_static6679✕16.466✕16.4
CSS.vi_static108108✕16.4108✕16.4
CSS.vmax_static6679✕16.466✕16.4
CSS.vmin_static6679✕16.466✕16.4
CSS.vw_static6679✕16.466✕16.4