JavaScript Document selectedStyleSheetSet Property

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated
Non-standard
Instance property

What You’ll Learn

Document.selectedStyleSheetSet is a deprecated instance property that names the style sheet set currently in use. Learn how to read and (in legacy browsers) set it, its link to enableStyleSheetsForSet and lastStyleSheetSet, and modern CSS theme alternatives.

01

Kind

Get / set property

02

Returns

Set name string

03

Status

Deprecated

04

Live

disabled sync

05

Sets

lastStyleSheetSet

06

Prefer

CSS class themes

Introduction

In the early web, authors could link multiple stylesheets with title attributes and let users (or scripts) switch between named style sheet sets—for example “Default” vs “High contrast.” document.selectedStyleSheetSet reports which set is active.

MDN: the selectedStyleSheetSet property indicates the name of the style sheet set that’s currently in use. You can read it and, in supporting browsers, assign a new set name to switch themes.

💡
The writable legacy switch

Among the three set properties (preferred, selected, last), selectedStyleSheetSet is the one scripts used to change themes. MDN: assigning it is equivalent to enableStyleSheetsForSet() plus updating lastStyleSheetSet.

Related Document tutorials: preferredStyleSheetSet, lastStyleSheetSet, adoptedStyleSheets, Document constructor.

Understanding Document.selectedStyleSheetSet

A get/set instance property from the alternate stylesheet era. MDN marks it deprecated and non-standard.

  • Value — name of the style sheet set currently in use (MDN).
  • Assignment — switches active set; updates lastStyleSheetSet (MDN).
  • Live — changing disabled on stylesheets affects this value (MDN).
  • Equivalent todocument.enableStyleSheetsForSet(name) when setting (MDN).
  • Status — Deprecated and Non-standard (MDN).

📝 Syntax

JavaScript
document.selectedStyleSheetSet

Read and write (MDN)

JavaScript
console.log(`Current style sheet set: ${document.selectedStyleSheetSet}`);

document.selectedStyleSheetSet = "Some other style sheet";

⚡ Quick Reference

GoalCode / note
Read active setdocument.selectedStyleSheetSet
Switch set (legacy)document.selectedStyleSheetSet = "Dark"
Feature detect"selectedStyleSheetSet" in document
Author defaultdocument.preferredStyleSheetSet
Last changed setdocument.lastStyleSheetSet
Modern themesdocument.documentElement.classList.toggle("dark")

🔍 At a Glance

Four facts about document.selectedStyleSheetSet.

Type
string

Get/set

Status
deprecated

Avoid

Live
true

MDN

Prefer
CSS themes

Modern

📋 Legacy Sets vs Modern CSS Themes

selectedStyleSheetSetClass on <html>
MDN statusDeprecated + Non-standardBaseline standard CSS/DOM
Browser supportLimited / removedAll modern browsers
Switch mechanismNamed stylesheet setsclassList.toggle("dark")
Use in 2026?NoYes

Examples Gallery

Examples follow MDN Document: selectedStyleSheetSet. Many browsers will report the property as missing—that is expected.

📚 Getting Started

Detect support and safely read the legacy property.

Example 1 — Feature Detect selectedStyleSheetSet

Never assume the property exists.

JavaScript
const supported = "selectedStyleSheetSet" in document;
console.log("selectedStyleSheetSet supported?", supported);
Try It Yourself

How It Works

Because MDN marks the API deprecated and non-standard, missing support is normal.

Example 2 — Read Current Set (MDN)

MDN logs the active style sheet set name.

JavaScript
if ("selectedStyleSheetSet" in document) {
  console.log(`Current style sheet set: ${document.selectedStyleSheetSet}`);
} else {
  console.log("Property not available in this browser");
}
Try It Yourself

How It Works

When supported, the string matches the title of the enabled alternate stylesheet group.

📈 MDN Set Pattern, Compare & Modern Themes

Legacy switching and the recommended replacement.

Example 3 — MDN: Assign a New Set Name

Switch themes by assigning selectedStyleSheetSet (legacy only).

JavaScript
if ("selectedStyleSheetSet" in document) {
  console.log(`Before: ${document.selectedStyleSheetSet}`);
  document.selectedStyleSheetSet = "Some other style sheet";
  console.log(`After: ${document.selectedStyleSheetSet}`);
} else {
  console.log("Cannot switch — API not supported");
}
Try It Yourself

How It Works

MDN: assignment calls enableStyleSheetsForSet() and updates lastStyleSheetSet.

Example 4 — Compare Preferred, Selected, and Last

Inspect all three legacy set properties together.

JavaScript
function reportStyleSheetSets() {
  if (!("selectedStyleSheetSet" in document)) {
    return "Style sheet set API not supported";
  }
  return {
    preferred: document.preferredStyleSheetSet,
    selected: document.selectedStyleSheetSet,
    last: document.lastStyleSheetSet
  };
}

console.log(reportStyleSheetSets());
Try It Yourself

How It Works

selected is the active set; changing it updates last but not preferred.

Example 5 — Modern Theme Class Toggle (Recommended)

Replace alternate stylesheets with a standard class on <html>.

JavaScript
document.getElementById("theme-btn").addEventListener("click", () => {
  document.documentElement.classList.toggle("dark");
  const isDark = document.documentElement.classList.contains("dark");
  console.log("theme:", isDark ? "dark" : "light");
});
Try It Yourself

How It Works

Pair with CSS like :root.dark { color-scheme: dark; ... } for portable theming.

🚀 Common Use Cases

  • Legacy code audits — find old theme switchers using set names.
  • Migration planning — map set names to CSS class themes.
  • Teaching history — explain pre-CSS-variable theme APIs.
  • Do not use for new themes — use class toggles or custom properties.
  • Firefox-era pages — some very old docs reference this API.
  • Interviews — know the modern replacement by heart.

🧠 How selectedStyleSheetSet Worked

1

Author defines named sets

<link rel="stylesheet" title="Dark" ...> groups styles.

Markup
2

Browser tracks active set

selectedStyleSheetSet exposes the current name (MDN).

Read
3

Script assigns new set name

Enables matching stylesheets and updates lastStyleSheetSet (MDN).

Write
4

Today: CSS class themes

Toggle dark on documentElement for reliable, standard switching.

📝 Notes

  • MDN: Deprecated and Non-standard — both banners shown above.
  • Value is live — toggling disabled on stylesheets affects it (MDN).
  • Setting the property updates lastStyleSheetSet; calling enableStyleSheetsForSet() alone does not (MDN).
  • Often unavailable in Chromium and other modern engines.
  • Related: preferredStyleSheetSet, lastStyleSheetSet, adoptedStyleSheets.

Browser Support

Document.selectedStyleSheetSet is marked Deprecated and Non-standard on MDN. Do not rely on it in new apps. Logos use the shared browser-image-sprite.png sprite from this project.

Deprecated · Non-standard

Document.selectedStyleSheetSet

Legacy active style sheet set — read/write in old browsers; use CSS class themes today.

Legacy Avoid in new code
Google Chrome Generally not available
No / removed
Mozilla Firefox Legacy / may be limited
Legacy only
Apple Safari Not reliable
No / limited
Microsoft Edge Chromium — generally not available
No / removed
Opera Follow Chromium
No / removed
Internet Explorer Legacy era only
Legacy only
Document.selectedStyleSheetSet Limited / removed

Bottom line: Feature-detect if you must read legacy code. Prefer CSS class themes, custom properties, or adoptedStyleSheets for modern theme switching.

Conclusion

Document.selectedStyleSheetSet named the active alternate style sheet set and could switch sets when assigned. MDN deprecates the entire API. Modern pages should use CSS classes, custom properties, or adoptedStyleSheets instead.

Continue with styleSheetSets, preferredStyleSheetSet, lastStyleSheetSet, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect before reading or writing
  • Migrate legacy set names to CSS class themes
  • Use document.documentElement.classList for dark mode
  • Learn the trio: preferred, selected, last (for audits only)
  • Prefer prefers-color-scheme for system themes

❌ Don’t

  • Build new theme UIs on selectedStyleSheetSet
  • Assume Chromium supports the API
  • Confuse selected (active) with preferred (author default)
  • Expect enableStyleSheetsForSet() to update last alone
  • Ignore the live disabled sync behavior in legacy code

Key Takeaways

Knowledge Unlocked

Five things to remember about document.selectedStyleSheetSet

Legacy active set — read/write in old browsers only.

5
Core concepts
✎️02

Writable

legacy switch

MDN
⚠️03

Status

deprecated

Avoid
🔄04

Live

disabled sync

MDN
05

Prefer

CSS themes

Modern

❓ Frequently Asked Questions

The name of the style sheet set currently in use on the page (MDN). It indicates which alternate stylesheet group is active.
Yes. MDN marks Document.selectedStyleSheetSet as Deprecated and Non-standard. Do not use it in new code.
Yes in supporting browsers. MDN: setting the value is equivalent to calling document.enableStyleSheetsForSet() with that name, then setting lastStyleSheetSet to the same value.
Yes. MDN notes the attribute value is live — directly changing the disabled attribute on stylesheets affects selectedStyleSheetSet.
preferredStyleSheetSet is the author default (read-only, may be empty string). selectedStyleSheetSet is the currently active set and can be read or written by scripts (MDN).
Prefer toggling a class on document.documentElement, CSS custom properties, prefers-color-scheme, or adoptedStyleSheets for constructable stylesheets.
Did you know?

MDN states that assigning document.selectedStyleSheetSet is equivalent to calling enableStyleSheetsForSet() with the new value, then setting lastStyleSheetSet to match. That is why lastStyleSheetSet only changes when selectedStyleSheetSet is assigned—not when the method alone is called.

Next: styleSheetSets

Learn the legacy live list of every available alternate style sheet set name.

styleSheetSets →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful