Outer loop. Visit each stylesheet in document order.
Try cssRules. Same-origin sheets expose their rule list.
Catch errors. Cross-origin sheets often throw SecurityError.
Log selectors.selectorText is handy for style rules (MDN demo idea).
Compatibility
Browser Support
Document.styleSheets is Baseline Widely available on MDN (since July 2015). It is a standard CSSOM property across modern browsers.
✓ Baseline · Widely available
Document.styleSheets
Read-only StyleSheetList of linked and embedded CSSStyleSheet objects.
98%Modern browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
styleSheetsExcellent
Bottom line: Safe for production. Remember: reading cssRules on cross-origin sheets may throw — use try/catch.
Frequently Asked Questions
A read-only StyleSheetList of CSSStyleSheet objects for stylesheets explicitly linked into or embedded in the document (MDN).
No. MDN marks Document.styleSheets as Baseline Widely available (since July 2015). It is part of the standard CSS Object Model (CSSOM).
MDN: Link header stylesheets come first (header order), then DOM stylesheets (tree order).
Loop document.styleSheets and compare sheet.title to your target name (MDN example pattern).
Only same-origin stylesheets. Cross-origin sheets may throw a SecurityError when accessing cssRules — wrap reads in try/catch.
document.styleSheets lists linked and embedded document stylesheets. document.adoptedStyleSheets holds constructable stylesheets you attach via JavaScript.