W3cubDocs

/Web APIs

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

CSSNumericValue.parse(cssText)

Parameters

cssText

a string containing numeric and unit parts.

Return value

A CSSNumericValue.

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.

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

Specifications

Browser compatibility

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