Skip to main content

CSSUnitValue

The CSSUnitValue interface of the CSS Typed Object Model API represents values that contain a single unit type. For example, "42px" would be represented by a CSSNumericValue.

MDN Reference

Extends

Methods

add()

add(...values): CSSNumericValue;

The add() method of the CSSNumericValue interface adds a supplied number to the CSSNumericValue.

MDN Reference

Parameters

ParameterType
...valuesCSSNumberish[]

Returns

CSSNumericValue

Inherited from

CSSNumericValue.add


div()

div(...values): CSSNumericValue;

The div() method of the CSSNumericValue interface divides the CSSNumericValue by the supplied value.

MDN Reference

Parameters

ParameterType
...valuesCSSNumberish[]

Returns

CSSNumericValue

Inherited from

CSSNumericValue.div


equals()

equals(...value): boolean;

The equals() method of the CSSNumericValue interface returns a boolean indicating whether the passed value are strictly equal. To return a value of true, all passed values must be of the same type and value and must be in the same order. This allows structural equality to be tested quickly.

MDN Reference

Parameters

ParameterType
...valueCSSNumberish[]

Returns

boolean

Inherited from

CSSNumericValue.equals


max()

max(...values): CSSNumericValue;

The max() method of the CSSNumericValue interface returns the highest value from among the values passed. The passed values must be of the same type.

MDN Reference

Parameters

ParameterType
...valuesCSSNumberish[]

Returns

CSSNumericValue

Inherited from

CSSNumericValue.max


min()

min(...values): CSSNumericValue;

The min() method of the CSSNumericValue interface returns the lowest value from among those values passed. The passed values must be of the same type.

MDN Reference

Parameters

ParameterType
...valuesCSSNumberish[]

Returns

CSSNumericValue

Inherited from

CSSNumericValue.min


mul()

mul(...values): CSSNumericValue;

The mul() method of the CSSNumericValue interface multiplies the CSSNumericValue by the supplied value.

MDN Reference

Parameters

ParameterType
...valuesCSSNumberish[]

Returns

CSSNumericValue

Inherited from

CSSNumericValue.mul


sub()

sub(...values): CSSNumericValue;

The sub() method of the CSSNumericValue interface subtracts a supplied number from the CSSNumericValue.

MDN Reference

Parameters

ParameterType
...valuesCSSNumberish[]

Returns

CSSNumericValue

Inherited from

CSSNumericValue.sub


to()

to(unit): CSSUnitValue;

The to() method of the CSSNumericValue interface converts a numeric value from one unit to another.

MDN Reference

Parameters

ParameterType
unitstring

Returns

CSSUnitValue

Inherited from

CSSNumericValue.to


toString()

toString(): string;

Returns

string

Inherited from

CSSNumericValue.toString


toSum()

toSum(...units): CSSMathSum;

The toSum() method of the CSSNumericValue interface converts the object's value to a CSSMathSum object to values of the specified unit.

MDN Reference

Parameters

ParameterType
...unitsstring[]

Returns

CSSMathSum

Inherited from

CSSNumericValue.toSum


type()

type(): CSSNumericType;

The type() method of the CSSNumericValue interface returns the type of CSSNumericValue, one of angle, flex, frequency, length, resolution, percent, percentHint, or time.

MDN Reference

Returns

CSSNumericType

Inherited from

CSSNumericValue.type

Properties

unit

readonly unit: string;

The CSSUnitValue.unit read-only property of the CSSUnitValue interface returns a string indicating the type of unit.

MDN Reference


value

value: number;

The CSSUnitValue.value property of the CSSUnitValue interface returns a double indicating the number of units.

MDN Reference