W3cubDocs

/Web APIs

CSSNumericValue: parse() static method

The parse() static method of the CSSNumericValue interface converts a value string into an object whose members are value and the units.

Syntax

js

CSSNumericValue.parse(cssText)

Parameters

cssText

a string containing numeric and unit parts.

Return value

Exceptions

Examples

The following returns a CSSUnitValue object with a unit property equal to "px" and a value property equal to 42.

js

let numValue = CSSNumericValue.parse("42.0px");

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
parse_static
66Not exposed to PaintWorklet.
79Not exposed to PaintWorklet.
No No
53Not exposed to PaintWorklet.
16.4
66Not exposed to PaintWorklet.
66Not exposed to PaintWorklet.
No
47Not exposed to PaintWorklet.
16.4
9.0Not exposed to PaintWorklet.

© 2005–2023 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