Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2023.
* Some parts of this feature may have varying levels of support.
The CSSStyleSheet() constructor creates a new CSSStyleSheet object which represents a single Stylesheet.
After constructing a stylesheet the CSSStyleSheet.replace(), CSSStyleSheet.replaceSync(), CSSStyleSheet.insertRule(), and CSSStyleSheet.deleteRule() methods can be used to modify the rules of the new stylesheet.
A stylesheet created using this method is referred to as a "constructed stylesheet". A constructed stylesheet can be shared between a document and its shadow DOM subtrees using ShadowRoot.adoptedStyleSheets and Document.adoptedStyleSheets.
An object containing the following:
baseURL OptionalA string containing the baseURL used to resolve relative URLs in the stylesheet.
media OptionalA MediaList containing a list of media rules, or a string containing a single rule.
disabled OptionalA Boolean indicating whether the stylesheet is disabled. False by default.
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.
The code below shows the sheet being constructed and then CSSStyleSheet.replaceSync() is called to add a rule to the sheet.
We then create a ShadowRoot and pass the sheet object to the ShadowRoot.adoptedStyleSheets property inside an array.
We can modify the stylesheets after they have been added to the array. Below we append a new rule to the same sheet using CSSStyleSheet.insertRule().
The same sheet can be shared with multiple shadow subtrees in the same document. For more examples see ShadowRoot.adoptedStyleSheets.
| CSS Object Model (CSSOM) # dom-cssstylesheet-cssstylesheet |
Enable JavaScript to view this browser compatibility table.
This page was last modified on May 4, 2026 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.