CSSMediaRule: media property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.

The read-only media property of the CSSMediaRule interface returns a MediaList representing the intended destination medium for style information.

Value

Examples

The CSS includes a media query with one style rule. This will be the first CSSRule returned by document.styleSheets[0].cssRules. Calling myRules[0].media therefore returns a MediaList object representing the media query.

css
@media (min-width: 500px) {
  body {
    color: blue;
  }
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].media); // a MediaList

Specifications

Specification
CSS Conditional Rules Module Level 3
# dom-cssmediarule-media

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
media

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support