Document.styleSheets

The styleSheets read-only property of the Document interface returns a StyleSheetList of CSSStyleSheet objects, for stylesheets explicitly linked into or embedded in a document.

Syntax

document.styleSheets

Value

The returned list is ordered as follows:

  • StyleSheets retrieved from <link> headers are placed first, sorted in header order.
  • StyleSheets retrieved from the DOM are placed after, sorted in tree order.

Examples

function getStyleSheet(unique_title) {
  for (const sheet of document.styleSheets) {
    if (sheet.title === unique_title) {
      return sheet;
    }
  }
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
styleSheets
1
12
1
4
≤12.1
4
1
18
4
≤12.1
3.2
1.0

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/styleSheets