For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.
Interface CSSStyleSheet
cssRules: CSSRuleList;
disabled: boolean;
href: string | null;
ownerNode: Element | ProcessingInstruction | null;
ownerRule: CSSRule | null;
parentStyleSheet: CSSStyleSheet | null;
rules: CSSRuleList;
title: string | null;
type: string;
get media(): MediaList;
set media(mediaText: string): void;
addRule(selector?: string, style?: string, index?: number): number;
deleteRule(index: number): void;
insertRule(rule: string, index?: number): number;
removeRule(index?: number): void;
replace(text: string): Promise<CSSStyleSheet>;
replaceSync(text: string): void;
}
Hierarchy (View Summary)
- StyleSheet
- CSSStyleSheet
Properties
ReadonlycssRules
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
The disabled property of the StyleSheet interface determines whether the style sheet is prevented from applying to the document.
Readonlyhref
The href property of the StyleSheet interface returns the location of the style sheet.
ReadonlyownerNode
The ownerNode property of the StyleSheet interface returns the node that associates this style sheet with the document.
ReadonlyownerRule
ReadonlyparentStyleSheet
The parentStyleSheet property of the StyleSheet interface returns the style sheet, if any, that is including the given style sheet.
Readonlyrules
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.
Readonlytitle
The title property of the StyleSheet interface returns the advisory title of the current style sheet.
Readonlytype
The type property of the StyleSheet interface specifies the style sheet language for the given style sheet.
Accessors
media
-
The read-only
mediaproperty of the StyleSheet interface contains a MediaList object representing the intended destination media for style information.Returns MediaList
-
set media(mediaText: string): void
Parameters
- mediaText: string
Returns void
Methods
addRule
-
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
Optionalselector: stringOptionalstyle: stringOptionalindex: number
Returns number
deleteRule
-
The CSSStyleSheet method
deleteRule()removes a rule from the stylesheet object.Parameters
- index: number
Returns void
insertRule
-
The
CSSStyleSheet.insertRule()method inserts a new CSS rule into the current style sheet.Parameters
- rule: string
Optionalindex: number
Returns number
removeRule
replace
-
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
- text: string
Returns Promise<CSSStyleSheet>
replaceSync
-
The
replaceSync()method of the CSSStyleSheet interface synchronously replaces the content of the stylesheet with the content passed into it.Parameters
- text: string
Returns void
The
CSSStyleSheetinterface 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.MDN Reference