English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSSStyleDeclaration setProperty() Method

 JavaScript CSSStyleDeclaration Object

setProperty()The function is used to: set a new value for the attribute of the CSS style declaration object.

Syntax:

object.setProperty(property, value, priority)
var declaration = document.styleSheets[0].rules[0].style;
declaration.setProperty('color',39;coral');
Test See‹/›

Browser Compatibility

All browsers fully support the setProperty() method:

Method
setProperty()YesYesYesYesYes

Parameter Value

ParameterDescription
property(Required) A string representing the name of the attribute to be added or modified
value(Optional) A string representing the new value
priority(Optional) A string indicating whether the priority of the attribute should be set to important
Accepts the following values:
  • "important"

  • undefined

  • ;39;39;

Technical Details

Return Value:Undefined
DOM Version:CSS Object Model

 JavaScript CSSStyleDeclaration Object