dom / latest / cssnumericvalue / parse.html /

CSSNumericValue.parse()

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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

Syntax

parse(cssText)

Parameters

cssText

a string containing numeric and unit parts.

Return value

Exceptions

SyntaxError

TBD

Examples

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");

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
66
Not exposed to PaintWorklet.
79
Not exposed to PaintWorklet.
No
No
53
Not exposed to PaintWorklet.
No
66
Not exposed to PaintWorklet.
66
Not exposed to PaintWorklet.
No
47
Not exposed to PaintWorklet.
No
9.0
Not exposed to PaintWorklet.

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