AwaitedDOM/ CSSStyleDeclaration

The CSSStyleDeclaration interface represents an object that is a CSS declaration block, and exposes style information and various style-related methods and properties.
A CSSStyleDeclaration object can be exposed using three different APIs:

Properties

.cssFloat
W3C

The cssFloat attribute can be set for elements that generate boxes that are not absolutely positioned. The cssFloat attribute corresponds to the float Cascading Style Sheets (CSS) property. Getting this attribute is equivalent to calling the getProperty method. Setting this attribute is equivalent to calling the setProperty method.

Type: Promise<string>

.cssText
W3C

Textual representation of the declaration block. Setting this attribute changes the style.

Type: Promise<string>

.length
W3C

The number of properties. See the item() method below.

Type: Promise<number>

.parentRule
W3C

The containing CSSRule.

Type: CSSRule

Methods

.getPropertyPriority(property)
W3C

Returns the optional priority, "important".

Arguments:

  • property string. property is a string representing the property name to be checked.

Returns: Promise<string>

.getPropertyValue(property)
W3C

Returns the property value given a property name.

Arguments:

  • property string. property is a string representing the property name (hyphen case) to be checked.

Returns: Promise<string>

.item(index)
W3C

Returns a property name.

Arguments:

  • index number. index is the index of the node to be fetched. The index is zero-based.

Returns: Promise<string>

.removeProperty(property)
W3C

Removes a property from the CSS declaration block.

Arguments:

  • property string. property is a string representing the property name to be removed. Note that multi-word property names are hyphenated and not camel-cased.

Returns: Promise<string>

.setProperty(property, value, priority?)
W3C

Modifies an existing CSS property or creates a new CSS property in the declaration block.

Arguments:

  • property string. propertyName is a string representing the CSS property name (hyphen case) to be modified.
  • value string. value Optional is a string containing the new property value. If not specified, treated as the empty string.
    • Note: *value* must not contain "!important" -- that should be set using the *priority* parameter.
  • priority string. priorityOptional is a string allowing the "important" CSS priority to be set. If not specified, treated as the empty string. The following values are accepted:
    • String value "important"
    • Keyword undefined
    • String empty value ""

Returns: Promise<void>

Edit this page on GitHub