W3cubDocs

/DOM

CSSMediaRule

The CSSMediaRule is an interface representing a single CSS @media rule. It implements the CSSConditionRule interface, and therefore the CSSGroupingRule and the CSSRule interface with a type value of 4 (CSSRule.MEDIA_RULE).

Syntax

The syntax is described using the WebIDL format.

interface CSSMediaRule : CSSConditionRule {
    readonly attribute MediaList media;
}

Properties

As a CSSConditionRule, and therefore both a CSSGroupingRule and a CSSRule, CSSMediaRule also implements the properties of these interfaces. It has the following specific property:

CSSMediaRule.media Read only
Specifies a MediaList representing the intended destination medium for style information.

Methods

As a CSSConditionRule, and therefore both a CSSGroupingRule and a CSSRule, CSSMediaRule also implements the methods of that interface. It has no specific methods.

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 45 Yes 17
17
Before Firefox 20, conditionText could not be set.
? ? ?
media ? ? ? ? ? ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 45 45 Yes 17
17
Before Firefox 20, conditionText could not be set.
? ? ?
media ? ? ? ? ? ? ?

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSMediaRule