StylePropertyMap: set() method

Baseline 2026
Newly available

Since November 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Want more browser support for this feature? Tell us why.

The set() method of the StylePropertyMap interface changes the CSS declaration using the given property.

Syntax

js
set(property)
set(property, value1)
set(property, value1, value2)
set(property, value1, value2, /* …, */ valueN)

Parameters

property

An identifier indicating the stylistic feature (e.g., font, width, background color) to change.

value1, …, valueN

The value(s) the given property should have.

Return value

None (undefined).

Examples

Basic usage

This example sets the specified value for the padding-top property within the element's style attribute.

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

Specification
CSS Typed OM Level 1
# dom-stylepropertymap-set

Browser compatibility