CSSImportRule.media

The read-only media property of the CSSImportRule interface returns a MediaList object, containing the value of the media attribute of the associated stylesheet.

Syntax

var media = CSSImportRule.media;

Value

A MediaList object.

Examples

The following stylesheet includes a single @import rule. Therefore the first item in the list of CSS rules will be a CSSImportRule. The media property returns a MediaList object. This includes the mediaText property with a value of screen.

@import url("style.css") screen;
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].media); //returns a MediaList

Specifications

Browser compatibility

BCD tables only load in the browser