JavaScript Document adoptedStyleSheets Property

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline Widely available
Instance property

What You’ll Learn

The adoptedStyleSheets property holds an array of constructed CSSStyleSheet objects applied to the document. Learn how to build styles with new CSSStyleSheet(), adopt them with push(), update rules live with insertRule(), and share sheets with Shadow DOM—with five examples and try-it labs.

01

Kind

Instance property

02

Type

CSSStyleSheet[]

03

Build with

CSSStyleSheet()

04

Mutate

push / insertRule

05

Share

Shadow DOM

06

Status

Baseline widely

Introduction

Most pages load CSS from <link> tags or @import. A constructed stylesheet is different: you create it in JavaScript with new CSSStyleSheet() and add rules programmatically.

document.adoptedStyleSheets is where those constructed sheets are registered on the document. Once adopted, their rules participate in the normal CSS cascade—MDN notes they are ordered after document.styleSheets when specificity and order are resolved.

💡
Constructed vs linked CSS

Linked stylesheets are created by the browser when you import a file. Constructed sheets are built in JS—ideal for component libraries, design tokens, and sharing one sheet across light DOM and shadow roots.

Related Document tutorials: Document constructor, activeElement. Shadow roots use the same idea via shadowRoot.adoptedStyleSheets.

Understanding Document.adoptedStyleSheets

An instance property whose value is an array of CSSStyleSheet instances. Each sheet must have been created with the CSSStyleSheet() constructor in the same document context.

  • Value — a mutable array; use push(), splice(), or assign a new array.
  • Live updates — changing rules on a sheet updates every document or shadow root that adopted it.
  • Cascade — adopted sheets apply alongside regular stylesheets via the CSS cascade algorithm.
  • Same-document only — sheets from another document (iframe) throw when adopted.
  • Baseline Widely available on MDN (since March 2023).

📝 Syntax

JavaScript
document.adoptedStyleSheets

Value

An array of CSSStyleSheet objects constructed in the current document.

MDN adopt pattern

JavaScript
const sheet = new CSSStyleSheet();
sheet.replaceSync("a { color: red; }");

document.adoptedStyleSheets.push(sheet);

⚡ Quick Reference

GoalCode / note
Create sheetconst sheet = new CSSStyleSheet()
Add rules (sync)sheet.replaceSync("p { margin: 0; }")
Adopt on documentdocument.adoptedStyleSheets.push(sheet)
Add one rule latersheet.insertRule("* { box-sizing: border-box; }")
Share with shadowshadow.adoptedStyleSheets = [sheet]
MDN statusBaseline Widely available (since March 2023)

🔍 At a Glance

Four facts about document.adoptedStyleSheets.

Type
CSSStyleSheet[]

Mutable array

Source
constructed

CSSStyleSheet()

Cascade
after styleSheets

MDN order

Baseline
widely

Since Mar 2023

Examples Gallery

Examples follow MDN Document: adoptedStyleSheets. Use View Output or Try It Yourself for each case.

📚 Getting Started

Build a constructed sheet and adopt it on the document.

Example 1 — MDN Adopt a Stylesheet

Create a sheet, add a rule with replaceSync, then push it.

JavaScript
const sheet = new CSSStyleSheet();
sheet.replaceSync("a { color: red; }");

document.adoptedStyleSheets.push(sheet);
// All <a> links on the page can now render red (if no higher-specificity rule wins)
Try It Yourself

How It Works

The sheet is empty until replaceSync runs. push registers it on the document without replacing the whole array.

Example 2 — Add Rules with insertRule()

After adoption, append another rule—the page updates immediately.

JavaScript
const sheet = new CSSStyleSheet();
sheet.replaceSync("body { font-family: system-ui; }");
document.adoptedStyleSheets.push(sheet);

sheet.insertRule("* { background-color: #eff6ff; }");
// The document background updates without re-adopting the sheet
Try It Yourself

How It Works

Mutating the CSSStyleSheet object affects every adopter—document and any shadow roots sharing the same instance.

📈 Shadow DOM & Inspection

Share sheets and inspect what the browser exposes.

Example 3 — Share a Sheet with Shadow DOM (MDN)

One constructed sheet styles both the document and an open shadow root.

JavaScript
const sheet = new CSSStyleSheet();
sheet.replaceSync("p { color: teal; font-weight: bold; }");
document.adoptedStyleSheets.push(sheet);

const node = document.createElement("div");
const shadow = node.attachShadow({ mode: "open" });
shadow.innerHTML = "<p>Inside shadow</p>";
shadow.adoptedStyleSheets = [sheet];
Try It Yourself

How It Works

Web components often keep styles in shadow DOM while reusing a shared design-token sheet from the light document.

Example 4 — Feature-Detect Safely

Guard adoption when adoptedStyleSheets or CSSStyleSheet is missing.

JavaScript
const canAdopt =
  "adoptedStyleSheets" in document &&
  typeof CSSStyleSheet === "function";

console.log({
  canAdopt,
  currentCount: canAdopt ? document.adoptedStyleSheets.length : "N/A"
});
Try It Yourself

How It Works

On unsupported browsers, fall back to <style> injection or linked CSS instead of constructed sheets.

Example 5 — Inspect Adopted vs styleSheets

Compare the adopted array with the broader document.styleSheets list.

JavaScript
const sheet = new CSSStyleSheet();
sheet.replaceSync("h1 { letter-spacing: 0.05em; }");
document.adoptedStyleSheets.push(sheet);

console.log({
  adoptedCount: document.adoptedStyleSheets.length,
  styleSheetsCount: document.styleSheets.length,
  adoptedIsSameRef: document.adoptedStyleSheets[0] === sheet
});
Try It Yourself

How It Works

styleSheets includes linked, inline, and adopted sheets. adoptedStyleSheets is only the constructed subset you manage in JS.

🚀 Common Use Cases

  • Design systems — one token sheet shared by document and web components.
  • Runtime theming — swap rules without reloading CSS files.
  • Micro-frontends — inject scoped constructed sheets on navigation.
  • Shadow DOM styling — reuse the same CSSStyleSheet instance.
  • Testing — programmatic styles without editing HTML <link> tags.
  • Performance — avoid duplicate parsed stylesheets when sharing one object.

🔧 How Adoption Works

1

Construct a sheet

new CSSStyleSheet() in the current document.

Create
2

Add CSS rules

replaceSync() or insertRule() fills the sheet.

Rules
3

Adopt on document

document.adoptedStyleSheets.push(sheet) registers it.

Adopt
4

Cascade applies styles

Rules run after styleSheets per MDN ordering; live edits propagate everywhere the sheet is adopted.

📝 Notes

  • MDN: Baseline Widely available (since March 2023) — no Deprecated / Experimental / Non-standard banner.
  • Only CSSStyleSheet() instances from the current document may be adopted.
  • Prefer in-place array mutations (push) over reassigning when adding one sheet.
  • Editing a shared sheet updates document and every shadow root that adopted it.
  • Sheets from another frame/document throw a DOMException when adopted.
  • Related: Document constructor, ownerDocument, JavaScript hub.

Universal Browser Support

Document.adoptedStyleSheets is marked Baseline Widely available on MDN (since March 2023). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline · Widely available

Document.adoptedStyleSheets

Mutable CSSStyleSheet[] for constructed styles — share across document and Shadow DOM.

Universal Widely available
Google Chrome Full support · Desktop & Mobile
Full support
Mozilla Firefox Full support · Desktop & Mobile
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer No constructed stylesheet support
No
Document.adoptedStyleSheets Excellent

Bottom line: Use new CSSStyleSheet(), add rules with replaceSync or insertRule, then push onto document.adoptedStyleSheets. Share the same instance with shadowRoot.adoptedStyleSheets for component styling.

Conclusion

document.adoptedStyleSheets is the standard way to attach JavaScript-built CSSStyleSheet objects to a page. Build rules programmatically, adopt with push, and share the same sheet with shadow roots for consistent component styling.

Continue with alinkColor, ownerDocument, activeElement, Document constructor, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Create sheets with new CSSStyleSheet() in the same document
  • Use push() to add sheets to adoptedStyleSheets
  • Share one sheet instance across document and shadow roots when possible
  • Feature-detect before relying on constructed stylesheets
  • Keep fallback CSS for browsers without support

❌ Don’t

  • Adopt sheets constructed in another document or iframe
  • Assume adopted sheets beat every linked stylesheet (cascade still applies)
  • Forget that mutating a shared sheet affects all adopters
  • Mix up adoptedStyleSheets with styleSheets
  • Skip error handling when experimenting with cross-document sheets

Key Takeaways

Knowledge Unlocked

Five things to remember about adoptedStyleSheets

Programmatic CSS adoption on every Document.

5
Core concepts
🛠02

Build

CSSStyleSheet()

Create
🔗03

Share

shadow DOM

Pattern
🔄04

Live

insertRule

Update
🎯05

Baseline

since Mar 2023

Status

❓ Frequently Asked Questions

It is an instance property that holds an array of constructed CSSStyleSheet objects applied to the document. You add sheets created with new CSSStyleSheet() in the same document context.
No. MDN marks Document.adoptedStyleSheets as Baseline Widely available (since March 2023). It is not Deprecated, Experimental, or Non-standard.
Create a sheet with new CSSStyleSheet(), add rules with replaceSync() or insertRule(), then push it onto document.adoptedStyleSheets. You can also assign a new array if needed.
Yes. The same CSSStyleSheet instance can be adopted on document.adoptedStyleSheets and on shadowRoot.adoptedStyleSheets. Editing the sheet updates every adopter.
Only sheets constructed with CSSStyleSheet() in the current document may be adopted. Sheets from another document (such as an iframe) throw when added.
Adopted sheets participate in the normal CSS cascade. MDN states they are treated as coming after sheets in document.styleSheets when order matters.
Did you know?

In an earlier spec revision, adoptedStyleSheets was not mutable—you had to assign a whole new array to add a sheet. Modern browsers support in-place mutations like push(), which is the pattern MDN recommends today.

Next: alinkColor

Learn the deprecated active-link color property and CSS :active replacement.

alinkColor →

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