CSSNumericValue: parse() static method

Limited availability

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.

Syntax

js
CSSNumericValue.parse(cssText)

Parameters

cssText

a string containing numeric and unit parts.

Return value

Exceptions

SyntaxError DOMException

TBD

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

Specification
CSS Typed OM Level 1
# dom-cssnumericvalue-parse

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
parse() static method

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.