The StyleSheetList interface represents a list of StyleSheet.

It is an array-like object but can't be iterated over using Array methods. However It can be iterated over in a standard for loop over its indices, or converted to an Array.


Get document styleSheet objects with for loop

for (let i = 0; i < document.styleSheets.length; i++) {
  let styleSheet = document.styleSheets[i];

Get all CSS rules for the document using Array methods

const allCSS = [...document.styleSheets]
  .map(styleSheet => {
    try {
      return [...styleSheet.cssRules]
        .map(rule => rule.cssText)
    } catch (e) {
      console.log('Access to stylesheet %s is denied. Ignoring...', styleSheet.href);


Specification Status Comment
CSS Object Model (CSSOM)
The definition of 'CSSStyleSheetList' in that specification.
Working Draft

Browser compatibility

BCD tables only load in the browser