/
index.md
51 lines (35 loc) · 1.07 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
49
50
51
---
title: "StylePropertyMap: set() method"
short-title: set()
slug: Web/API/StylePropertyMap/set
page-type: web-api-instance-method
browser-compat: api.StylePropertyMap.set
---
{{APIRef("CSS Typed Object Model API")}}
The **`set()`** method of the {{domxref("StylePropertyMap")}}
interface changes the CSS declaration with the given property.
## Syntax
```js-nolint
set(property, value)
```
### Parameters
- `property`
- : An identifier indicating the stylistic feature (e.g. font, width, background
color) to change.
- `value`
- : The value the given property should have.
### Return value
None ({{jsxref("undefined")}}).
## Examples
This example sets the {{cssxref('padding-top')}} property, with the given value, within
the element's [style attribute](/en-US/docs/Web/HTML/Global_attributes/style).
```js
// get the button element
const buttonEl = document.querySelector("button");
// set padding-top on button style attribute
buttonEl.attributeStyleMap.set("padding-top", CSS.px(10));
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}