This feature is not Baseline because it does not work in some of the most widely-used browsers.
The parse() static method of the CSSNumericValue interface converts a value string into an object whose members are value and the units.
CSSNumericValue.parse(cssText)
cssTexta string containing numeric and unit parts.
SyntaxError DOMException
TBD
The following returns a CSSUnitValue object with a unit property equal to "px" and a value property equal to 42.
let numValue = CSSNumericValue.parse("42.0px");
| Specification |
|---|
| CSS Typed OM Level 1> # dom-cssnumericvalue-parse> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
parse_static |
66Not exposed to PaintWorklet. |
79Not exposed to PaintWorklet. |
No | 53Not exposed to PaintWorklet. |
16.4 | 66Not exposed to PaintWorklet. |
No | 47Not exposed to PaintWorklet. |
16.4 | 9.0Not exposed to PaintWorklet. |
66Not exposed to PaintWorklet. |
16.4 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/parse_static