Back to Content

CSSUnitValue: value property

files/en-us/web/api/cssunitvalue/value/index.md

latest785 B
Original Source

{{APIRef("CSS Typed Object Model API")}}

The CSSUnitValue.value property of the {{domxref("CSSUnitValue")}} interface returns a double indicating the number of units.

Value

A double.

Examples

The following creates a {{domxref('CSSPositionValue')}} from individual CSSUnitValue constructors, then queries the CSSUnitValue.value.

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

console.log(pos.x.value); // 5
console.log(pos.y.value); // 10

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also