The read-only media
property of the
CSSMediaRule
interface MediaList
represents the intended
destination medium for style information.
Syntax
var media = CSSMediaRule.media;
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.
@media (min-width: 500px) {
body {
color: blue;
}
}
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].media); // a MediaList
Specifications
Specification | Status | Comment |
---|---|---|
CSS Conditional Rules Module Level 3 The definition of 'CSSMediaRule.media' in that specification. |
Candidate Recommendation | Make it derived from the CSSConditionRule . |
Document Object Model (DOM) Level 2 Style Specification The definition of 'CSSMediaRule.media' in that specification. |
Obsolete | Initial definition. |
Browser compatibility
BCD tables only load in the browser
The compatibility table in this page is generated from structured data. If
you'd like to contribute to the data, please check out
https://github.com/mdn/browser-compat-data
and send us a pull request.