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.

Note: This method cannot be called in Worker or Worklet contexts — parsing CSS text is restricted to the main thread. All other methods in the CSSNumericValue interface are available in workers and worklets.

Syntax

js
CSSNumericValue.parse(cssText)

Parameters

cssText

a string containing numeric and unit parts.

Return value

A CSSNumericValue.

Exceptions

SyntaxError DOMException

TBD

Examples

undefined

Basic usage

The following code 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