CSSStyleSheet
The 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.
Extends
Accessors
media
Get Signature
get media(): MediaList;
The read-only media property of the StyleSheet interface contains a MediaList object representing the intended destination media for style information.
Returns
Set Signature
set media(mediaText): void;
Parameters
| Parameter | Type |
|---|---|
mediaText | string |
Returns
void
Inherited from
Methods
addRule()
addRule(
selector?,
style?,
index?
): number;
The obsolete CSSStyleSheet interface's addRule() legacy method adds a new rule to the stylesheet. You should avoid using this method, and should instead use the more standard insertRule() method.
Parameters
| Parameter | Type |
|---|---|
selector? | string |
style? | string |
index? | number |
Returns
number
Deprecated
deleteRule()
deleteRule(index): void;
The CSSStyleSheet method deleteRule() removes a rule from the stylesheet object.
Parameters
| Parameter | Type |
|---|---|
index | number |
Returns
void
insertRule()
insertRule(rule, index?): number;
The CSSStyleSheet.insertRule() method inserts a new CSS rule into the current style sheet.
Parameters
| Parameter | Type |
|---|---|
rule | string |
index? | number |
Returns
number
removeRule()
removeRule(index?): void;
The obsolete CSSStyleSheet method removeRule() removes a rule from the stylesheet object. It is functionally identical to the standard, preferred method deleteRule().
Parameters
| Parameter | Type |
|---|---|
index? | number |
Returns
void
Deprecated
replace()
replace(text): Promise<CSSStyleSheet>;
The replace() method of the CSSStyleSheet interface asynchronously replaces the content of the stylesheet with the content passed into it. The method returns a promise that resolves with the CSSStyleSheet object.
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
Promise<CSSStyleSheet>
replaceSync()
replaceSync(text): void;
The replaceSync() method of the CSSStyleSheet interface synchronously replaces the content of the stylesheet with the content passed into it.
Parameters
| Parameter | Type |
|---|---|
text | string |
Returns
void
Properties
cssRules
readonly cssRules: CSSRuleList;
The read-only CSSStyleSheet property cssRules returns a live CSSRuleList which provides a real-time, up-to-date list of every CSS rule which comprises the stylesheet. Each item in the list is a CSSRule defining a single rule.
disabled
disabled: boolean;
The disabled property of the StyleSheet interface determines whether the style sheet is prevented from applying to the document.
Inherited from
href
readonly href: string | null;
The href property of the StyleSheet interface returns the location of the style sheet.
Inherited from
ownerNode
readonly ownerNode:
| Element
| ProcessingInstruction
| null;
The ownerNode property of the StyleSheet interface returns the node that associates this style sheet with the document.
Inherited from
ownerRule
readonly ownerRule: CSSRule | null;
parentStyleSheet
readonly parentStyleSheet: CSSStyleSheet | null;
The parentStyleSheet property of the StyleSheet interface returns the style sheet, if any, that is including the given style sheet.
Inherited from
rules
readonly rules: CSSRuleList;
rules is a deprecated legacy property of the CSSStyleSheet interface. Functionally identical to the preferred cssRules property, it provides access to a live-updating list of the CSS rules comprising the stylesheet.
Deprecated
title
readonly title: string | null;
The title property of the StyleSheet interface returns the advisory title of the current style sheet.
Inherited from
type
readonly type: string;
The type property of the StyleSheet interface specifies the style sheet language for the given style sheet.