W3cubDocs

/Web APIs

Document: styleSheets property

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.

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

js

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 4.4 18 4 ≤12.1 3.2 1.0

© 2005–2023 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