CSSUnitValue: CSSUnitValue() constructor - Web APIs | MDN

Syntax

js

new CSSUnitValue(value, unit)

Parameters

value

A double indicating the number of units.

unit

A string indicating the type of unit.

Examples

The following shows a method of creating a CSSPositionValue from individual CSSUnitValue constructors.

js

let pos = new CSSPositionValue(
  new CSSUnitValue(5, "px"),
  new CSSUnitValue(10, "px"),
);

Specifications

Specification
CSS Typed OM Level 1
# dom-cssunitvalue-cssunitvalue

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.