The read-only length property of the MediaList interface returns the number of media queries in the list.
On this page
MediaList: length property
Value
A positive integer.
Examples
The following would log to the console the number of media queries stored in the MediaList associated with the first stylesheet applied to the current document.
js
const stylesheets = document.styleSheets;
const stylesheet = stylesheets[0];
console.log(stylesheet.media.length);
Specifications
| Specification |
|---|
| CSS Object Model (CSSOM) # dom-medialist-length |
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 | |
length |
1 | 12 | 1 | 9 | ≤12.1 | 1 | 4.4 | 18 | 4 | ≤12.1 | 1 | 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/MediaList/length