Path: blob/main/website/awaited-dom/CSSStyleDeclaration.md
1028 views
AwaitedDOM / CSSStyleDeclaration
CSSStyleDeclaration
interface represents an object that is a CSS declaration block, and exposes style information and various style-related methods and properties.CSSStyleDeclaration
object can be exposed using three different APIs:Properties
.cssFloat W3C {#cssFloat}
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 {#cssText}
Textual representation of the declaration block. Setting this attribute changes the style.
Type: Promise<string>
.length W3C {#length}
The number of properties. See the item()
method below.
Type: Promise<number>
.parentRule W3C {#parentRule}
The containing CSSRule
.
Type: CSSRule
Methods
.getPropertyPriority*(property)* W3C {#getPropertyPriority}
Returns the optional priority, "important".
Arguments:
property
string
.property
is astring
representing the property name to be checked.
Returns: Promise<string>
.getPropertyValue*(property)* W3C {#getPropertyValue}
Returns the property value given a property name.
Arguments:
property
string
.property
is astring
representing the property name (hyphen case) to be checked.
Returns: Promise<string>
.item*(index)* W3C {#item}
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 {#removeProperty}
Removes a property from the CSS declaration block.
Arguments:
property
string
.property
is astring
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 {#setProperty}
Modifies an existing CSS property or creates a new CSS property in the declaration block.
Arguments:
property
string
.propertyName
is astring
representing the CSS property name (hyphen case) to be modified.value
string
.value
Optional is astring
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.
- Note: *
priority
string
.priority
Optional is astring
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
""
- String value