Path: blob/main/website/awaited-dom/CSSStyleSheet.md
1029 views
AwaitedDOM / CSSStyleSheet
CSSStyleSheet
interface represents a single CSS stylesheet, and lets you inspect and modify the list of rules contained in the stylesheet. It inherits properties and methods from its parent, StyleSheet
.CSSRule
objects representing each of the rules in the stylesheet. The rules are contained in a CSSRuleList
, which can be obtained from the stylesheet's cssRules
property.CSSStyleRule
object containing a style such as:Properties
.cssRules W3C {#cssRules}
Returns a live CSSRuleList
which maintains an up-to-date list of the CSSRule
objects that comprise the stylesheet.
This is normally used to access individual rules like this:
styleSheet.cssRules[i] // where i = 0..cssRules.length-1
To add or remove items in cssRules
, use the CSSStyleSheet
's insertRule()
and deleteRule()
methods.
Type: CSSRuleList
.ownerRule W3C {#ownerRule}
If this stylesheet is imported into the document using an @import
rule, the ownerRule
property returns the corresponding CSSImportRule
; otherwise, this property's value is null
.
Type: CSSRule
Methods
.deleteRule*(index)* W3C {#deleteRule}
Deletes the rule at the specified index into the stylesheet's rule list.
Arguments:
index
number
. The index into the stylesheet'sCSSRuleList
indicating the rule to be removed.
Returns: Promise<void>
.insertRule*(rule, index?)* W3C {#insertRule}
Inserts a new rule at the specified position in the stylesheet, given the textual representation of the rule.
Arguments:
rule
string
. Astring
containing the rule to be inserted. What the inserted rule must contain depends on its type:- **For rule-sets**, both a selector and a style declaration.
- **For at-rules**, both an at-identifier and the rule content.
index
number
. A positive integer less than or equal tostylesheet.cssRules.length
, representing the newly inserted rule's position inCSSStyleSheet.cssRules
. The default is0
. (In older implementations, this was required. See Browser compatibility for details.)
Returns: Promise<number>
Unimplemented Specs
Properties
disabled | href |
media | ownerNode |
parentStyleSheet | title |
type |