• Skip to main content
  • Skip to search
  • Skip to select language
    • Technologies Overview
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs
    • Browser Extensions
    • MathML
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
    • Send Feedback
    • Contribute to MDN
    • Report a content issue 🌐
    • Report a platform issue 🌐
  1. Web technology for developers
  2. Web APIs
  3. CSSRuleList
  4. CSSRuleList.length
  • Change language

Table of contents

  • Value
  • Examples
  • Specifications
  • Browser compatibility

CSSRuleList.length

The length property of the CSSRuleList interface returns the number of CSSRule objects in the list.

Value

An integer.

Examples

In the following example the number of items in the CSSRuleList named myRules is printed to the console.

let myRules = document.styleSheets[0].cssRules;
console.log(myRules.length);

Specifications

Specification
CSS Object Model (CSSOM)
# dom-cssrulelist-length

Browser compatibility

BCD tables only load in the browser

Found a problem with this page?

  • Edit on GitHub
  • Source on GitHub
  • Report a problem with this content on GitHub
  • Want to fix the problem yourself? See our Contribution guide.

Last modified: Mar 23, 2022, by MDN contributors

Change your language

Related Topics

  1. CSS Object Model
  2. CSSRuleList
  3. Properties
    1. length
  4. Methods
    1. item()
  5. Related pages for CSSOM
    1. AnimationEvent
    2. CSS
    3. CSSConditionRule
    4. CSSGroupingRule
    5. CSSKeyframeRule
    6. CSSKeyframesRule
    7. CSSMediaRule
    8. CSSNamespaceRule
    9. CSSPageRule
    10. CSSRule
    11. CSSStyleDeclaration
    12. CSSStyleRule
    13. CSSStyleSheet
    14. CSSSupportsRule
    15. CaretPosition
    16. LinkStyle
    17. MediaQueryList
    18. MediaQueryListListener
    19. Screen
    20. StyleSheet
    21. StyleSheetList
    22. TransitionEvent
  • Web Technologies
  • Learn Web Development
  • About MDN
  • Feedback
  • About
  • MDN Web Docs Store
  • Contact Us
  • Firefox

MDN

  • MDN on Twitter
  • MDN on Github

Mozilla

  • Mozilla on Twitter
  • Mozilla on Instagram

© 2005-2022 Mozilla and individual contributors. Content is available under these licenses.

  • Terms
  • Privacy
  • Cookies