CSSNumericValue

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The CSSNumericValue interface of the CSS Typed Object Model API represents operations that all numeric values can perform.

CSSStyleValue CSSNumericValue

Interfaces based on CSSNumericValue

Instance properties

None.

Static methods

CSSNumericValue.parse

Allows a CSSNumericValue to be constructed directly from a string containing CSS.

Instance methods

CSSNumericValue.add

Adds a supplied number to the CSSNumericValue.

CSSNumericValue.sub

Subtracts a supplied number from the CSSNumericValue.

CSSNumericValue.mul

Multiplies the CSSNumericValue by the supplied value.

CSSNumericValue.div

Divides the CSSNumericValue by the supplied value.

CSSNumericValue.min

Returns the minimum value passed

CSSNumericValue.max

Returns the maximum value passed

CSSNumericValue.equals

True if all the values are the exact same type and value, in the same order. Otherwise, false.

CSSNumericValue.to

Converts value into another one with the specified unit.

CSSNumericValue.toSum

Converts an existing CSSNumericValue into a CSSMathSum object with values of a specified unit.

CSSNumericValue.type

Returns the type of CSSNumericValue, one of angle, flex, frequency, length, resolution, percent, percentHint, or time.

Specifications

Specification
CSS Typed OM Level 1
# numeric-value

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
CSSNumericValue
add
div
equals
max
min
mul
parse() static method
sub
to
toSum
type

Legend

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

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

See also