{{ APIRef("CSSOM") }}
The CSSMediaRule
is an interface representing a single CSS {{cssxref("@media")}} rule. It implements the {{domxref("CSSConditionRule")}} interface, and therefore the {{domxref("CSSGroupingRule")}} and the {{domxref("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 {{ domxref("CSSConditionRule") }}, and therefore both a {{domxref("CSSGroupingRule")}} and a {{ domxref("CSSRule") }}, CSSMediaRule
also implements the properties of these interfaces. It has the following specific property:
- {{domxref("CSSMediaRule.media")}} {{readonlyinline()}}
- Specifies a {{domxref("MediaList")}} representing the intended destination medium for style information.
Methods
As a {{ domxref("CSSConditionRule") }}, and therefore both a {{domxref("CSSGroupingRule")}} and a {{ domxref("CSSRule") }}, CSSMediaRule
also implements the methods of that interface. It has no specific methods.
Specifications
Specification | Status | Comment |
---|---|---|
{{ SpecName('CSS3 Conditional', '#the-cssmediarule-interface', 'CSSMediaRule') }} | {{ Spec2('CSS3 Conditional')}} | Make it derived from the {{domxref("CSSConditionRule")}}. |
{{ SpecName('CSSOM', '#the-cssmediarule-interface', 'CSSMediaRule') }} | {{ Spec2('CSSOM') }} | No changes from {{SpecName('DOM2 Style')}} |
{{SpecName('DOM2 Style', 'css.html#CSS-CSSMediaRule', 'CSSMediaRule') }} | {{ Spec2('DOM2 Style') }} |
Browser compatibility
{{ CompatibilityTable() }}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{ CompatUnknown() }} | {{ CompatVersionUnknown }} [1] | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{ CompatUnknown() }} | {{ CompatGeckoMobile("17") }} [1] | {{ CompatUnknown() }} | {{ CompatUnknown() }} | {{ CompatUnknown() }} |
[1] Setting the value of conditionText
on Gecko is only possible from Firefox 20 onwards.
See also
- {{CSSOM}}