-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
48 lines (34 loc) · 1.03 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
title: "CSSUnitValue: unit property"
short-title: unit
slug: Web/API/CSSUnitValue/unit
page-type: web-api-instance-property
browser-compat: api.CSSUnitValue.unit
---
{{APIRef("CSS Typed Object Model API")}}
The **`CSSUnitValue.unit`** read-only property
of the {{domxref("CSSUnitValue")}} interface returns a string
indicating the type of unit.
## Value
A string.
## Examples
The following creates a {{domxref('CSSPositionValue')}} from individual
`CSSUnitValue` constructors, then queries the
`CSSUnitValue.unit`.
```js
const pos = new CSSPositionValue(
new CSSUnitValue(5, "px"),
new CSSUnitValue(10, "em"),
);
console.log(pos.x.unit); // "px"
console.log(pos.y.unit); // "em"
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref('CSSUnitValue.value')}}
- [Dimensions in CSS units and values](/en-US/docs/Web/CSS/CSS_Values_and_Units#dimensions)
- [Using the CSS Typed OM](/en-US/docs/Web/API/CSS_Typed_OM_API/Guide)
- [CSS Typed Object Model API](/en-US/docs/Web/API/CSS_Typed_OM_API)