Document.selectedStyleSheetSet indicates the style sheet set currently in use (MDN). You can also assign a set name to switch sheets in supporting browsers.
Read the notes below before you get or set this property. Prefer feature detection when support is limited.
Syntax
Use document.selectedStyleSheetSet. Start with this line.
JavaScript
document.selectedStyleSheetSet
Call
What it does
document.selectedStyleSheetSet
Primary signature.
Built into the browser. Read or assign document.selectedStyleSheetSet — no import required.
Library declarations
JavaScript
document.selectedStyleSheetSet
Parameters
Parameter
Description
Modern path
Required. Class / CSS / adoptedStyleSheets
Return Value
Return Value
Description
*
The current value of document.selectedStyleSheetSet.
JavaScript Examples
Example 1 — Read selectedStyleSheetSet
MDN-style log of the currently active style sheet set name.
JavaScript
if ("selectedStyleSheetSet" in document) {
console.log(
"Current style sheet set: " + document.selectedStyleSheetSet
);
} else {
console.log("API not available");
}
Branch. Log the value only when the property exists.
Expect gaps. Deprecated non-standard APIs are often incomplete.
Do not polyfill. Migrate themes instead of shimming this API.
Example 3 — Prefer a Modern Theme Toggle
Simple replacement pattern for light/dark themes without style sheet sets.
JavaScript
// Prefer this over selectedStyleSheetSet for new apps
document.documentElement.classList.toggle("dark");
console.log(
document.documentElement.classList.contains("dark")
);
Toggle a class. Put theme styles under .dark (or similar).
Target documentElement. The <html> root is the usual place.
Standard APIs. Works everywhere without alternate stylesheet menus.
Pair with CSS. Custom properties and prefers-color-scheme complete the story.
Compatibility
Browser Support
Document.selectedStyleSheetSet is Deprecated and Non-standard (MDN). Support is incomplete — feature-detect, and do not ship new features on it.
✓ Deprecated · Non-standard
Document.selectedStyleSheetSet
Legacy current style sheet set name — avoid in new apps.
LegacyAvoid in new apps
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
selectedStyleSheetSetDeprecated
Bottom line: Safe to recognize in old code. For themes: documentElement classes, CSS variables, prefers-color-scheme, or adoptedStyleSheets.
Frequently Asked Questions
The name of the style sheet set currently in use (MDN). It reflects which alternate stylesheet group is active.
Yes. MDN marks Document.selectedStyleSheetSet as Deprecated and Non-standard. Do not use it in new projects.
Yes in supporting browsers. MDN: setting it is equivalent to calling document.enableStyleSheetsForSet() with that name, then setting lastStyleSheetSet to the same value.
Yes. MDN notes the attribute value is live — changing the disabled attribute on stylesheets affects selectedStyleSheetSet.
preferredStyleSheetSet is the author default (read-only, often ""). selectedStyleSheetSet is the currently active set and can be read or written by scripts (MDN).
Prefer a class on document.documentElement, CSS custom properties, prefers-color-scheme, or adoptedStyleSheets. Avoid the alternate style sheet set DOM API for new work.