Document.lastStyleSheetSet is a deprecated, non-standard instance property that returns the last enabled style sheet set name. Learn how it relates to selectedStyleSheetSet, when it is null, how to feature-detect it, and what to use instead for themes.
01
Kind
Instance property
02
Returns
string | null
03
Status
Deprecated
04
Also
Non-standard
05
Updates on
selectedStyleSheetSet
06
Prefer
CSS themes
Fundamentals
Introduction
Years ago, HTML offered alternate stylesheets with <link rel="stylesheet" title="..."> and rel="alternate stylesheet". Browsers could switch among named “style sheet sets.” Document APIs like selectedStyleSheetSet and lastStyleSheetSet exposed that switching.
MDN: lastStyleSheetSet returns the last enabled style sheet set. Its value changes whenever document.selectedStyleSheetSet is changed. If the current set has never been changed that way, the value is null.
💡
Modern replacement
Today, theme UIs almost always toggle classes or CSS variables on <html> / <body>. That approach works everywhere and does not depend on this legacy API.
An instance property from the legacy style sheet set API.
Value — name of the last enabled set, or null if selectedStyleSheetSet was never changed (MDN).
Updates — when document.selectedStyleSheetSet changes (MDN).
Does not update — when document.enableStyleSheetsForSet() is called (MDN).
Status — Deprecated and Non-standard (MDN).
Support — often missing; always feature-detect.
Foundation
📝 Syntax
JavaScript
document.lastStyleSheetSet
Value
A string naming the style sheet set most recently set, or null if selectedStyleSheetSet has not been changed (MDN).
MDN example
JavaScript
let lastSheetSet = document.lastStyleSheetSet;
if (!lastSheetSet) {
lastSheetSet = "Style sheet not yet changed";
} else {
console.log(`The last style sheet set is: ${lastSheetSet}`);
}
When supported and never changed via selectedStyleSheetSet, MDN says the value is null.
📈 MDN Pattern, selectedStyleSheetSet & Modern Themes
Legacy behavior notes and the recommended replacement.
Example 3 — MDN: Fallback Message When Null
Treat a missing or null set as “not yet changed.”
JavaScript
let lastSheetSet =
"lastStyleSheetSet" in document
? document.lastStyleSheetSet
: null;
if (!lastSheetSet) {
lastSheetSet = "Style sheet not yet changed";
} else {
console.log(`The last style sheet set is: ${lastSheetSet}`);
}
console.log(lastSheetSet);
Adapted from MDN so unsupported browsers still show a clear message.
Example 4 — Relationship to selectedStyleSheetSet
MDN: lastStyleSheetSet updates when the selected set changes.
JavaScript
function reportStyleSheetSets() {
if (!("lastStyleSheetSet" in document)) {
return "Style sheet set API not supported";
}
return {
selected: document.selectedStyleSheetSet,
last: document.lastStyleSheetSet
};
}
console.log(reportStyleSheetSets());
Document.lastStyleSheetSet 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.lastStyleSheetSet
Legacy style sheet set name — last enabled set after selectedStyleSheetSet changes.
LegacyAvoid in new code
Google ChromeGenerally not available
No / removed
Mozilla FirefoxLegacy / may be limited
Legacy only
Apple SafariNot reliable
No / limited
Microsoft EdgeChromium — generally not available
No / removed
OperaFollow Chromium
No / removed
Internet ExplorerLegacy era only
Legacy only
Document.lastStyleSheetSetLimited / removed
Bottom line: Feature-detect if you must read legacy code. Prefer CSS class themes, custom properties, or adoptedStyleSheets for modern theme switching.
Wrap Up
Conclusion
Document.lastStyleSheetSet remembers the last style sheet set enabled via selectedStyleSheetSet. MDN marks it deprecated and non-standard, so treat it as history—build new themes with CSS classes and standard Document APIs instead.
Migrate legacy alternate-stylesheet UIs when you find them
❌ Don’t
Build new products on style sheet set APIs
Assume Chromium exposes lastStyleSheetSet
Expect enableStyleSheetsForSet to update this property
Skip null checks even in supporting browsers
Confuse this with document.styleSheets (live stylesheet list)
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about document.lastStyleSheetSet
A legacy style sheet set name — not for new code.
5
Core concepts
📄01
Returns
string | null
API
⚠️02
Status
Deprecated
MDN
🚫03
Also
Non-standard
Avoid
🔄04
Updates
selectedStyleSheetSet
MDN
🎨05
Prefer
CSS themes
Modern
❓ Frequently Asked Questions
The last enabled style sheet set name. The value changes when document.selectedStyleSheetSet is changed. If selectedStyleSheetSet has never been set, the value is null (MDN).
Yes. MDN marks Document.lastStyleSheetSet as Deprecated and Non-standard. Do not use it in new code.
No. MDN notes that this value does not change when document.enableStyleSheetsForSet() is called — only when selectedStyleSheetSet is changed.
Many modern browsers never implemented (or already removed) the alternate style sheet set API. Feature-detect before reading the property.
Prefer toggling a class on document.documentElement (for example dark), CSS custom properties, prefers-color-scheme, or adoptedStyleSheets for constructable stylesheets.
Only to understand legacy code. New theme switching should use CSS and standard DOM APIs, not style sheet sets.
Did you know?
Firefox once exposed a View → Page Style menu for alternate stylesheets. That UI, together with Document style sheet set properties, is part of why you may still see these names in very old tutorials—even though modern theme systems moved on.