StyleSheetList

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.

Examples

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 =
    [].slice.call(document.styleSheets)
        .reduce(function (prev, styleSheet) {
            let now = prev;
            try {
                if (styleSheet.cssRules) {
                    now += [].slice.call(styleSheet.cssRules)
                        .reduce(function (prev, cssRule) {
                            return prev + cssRule.cssText;
                        }, '');
                }
            } catch (e) {
                console.log('Access to cssRules for stylesheet "' + styleSheet.href + '" is denied. Ignoring...')
            }
            return now;
        }, '');

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
StyleSheetListChrome Full support 1Edge Full support YesFirefox Full support 31IE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 31Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
itemChrome Full support 1Edge Full support 12Firefox Full support 31IE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 31Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes
lengthChrome Full support 1Edge Full support 12Firefox Full support 31IE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 31Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown