CSSStyleSheet()
The CSSStyleSheet() constructor creates a new CSSStyleSheet object which represents a single Stylesheet.
After constructing a stylesheet the CSSStyleSheet.replace() or CSSStyleSheet.replaceSync() methods can be used to add rules to the new stylesheet.
Syntax
new CSSStyleSheet(); new CSSStyleSheet(options);
Parameters
-
optionsOptional -
An object containing the following:
Examples
In the following example a new CSSStyleSheet is constructed, with a media rule of "print". Printing StyleSheet.media to the console returns a MediaList with a single entry for this print rule.
let stylesheet = new CSSStyleSheet({media: 'print'}); console.log(stylesheet.media);
Specifications
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
CSSStyleSheet |
73 |
79 |
73
See bug 1520690.
|
No |
53 |
No |
73 |
73 |
No |
47 |
No |
9.0 |
Polyfill
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/CSSStyleSheet