for (const styleSheet of document.styleSheets) {
console.log(styleSheet); // A CSSStyleSheet object
}StyleSheetList / notebook
StyleSheetList
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const allCSS = [...document.styleSheets]
.map((styleSheet) => {
try {
return [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
} catch (e) {
console.log(
"Access to stylesheet %s is denied. Ignoring…",
styleSheet.href,
);
return undefined;
}
})
.filter(Boolean)
.join("\n");