Fetching contributors…
Cannot retrieve contributors at this time
986 lines (833 sloc) 37.5 KB
<pre class="metadata">
Title: CSS Conditional Rules Module Level 3
Group: csswg
Shortname: css-conditional
Level: 3
Status: ED
Work Status: Testing
Previous Version:
Test Suite:
Editor: L. David Baron, Mozilla,, w3cid 15393
Abstract: This module contains the features of CSS for conditional processing of parts of
style sheets, conditioned on capabilities of the processor or the
document the style sheet is being applied to. It includes and extends the
functionality of CSS level&nbsp;2 [[!CSS21]], which builds on CSS level&nbsp;1
[[CSS1]]. The main extensions compared to level&nbsp;2 are allowing nesting of
certain at-rules inside ''@media'', and the addition of the ''@supports'' rule for
conditional processing.
At Risk: The inclusion of @font-face rules and @keyframes rules as allowed within all of the @-rules in this specification is at risk, though only because of the relative rates of advancement of specifications. If this specification is able to advance faster than one or both of the specifications defining those rules, then the inclusion of those rules will move from this specification to the specification defining those rules.
At Risk: The addition of support for @-rules inside of conditional grouping rules is at risk; if interoperable implementations are not found, it may be removed to advance the other features in this specification to Proposed Recommendation.
At Risk: The @supports rule is at risk; if interoperable implementations are not found, it may be removed to advance the other features in this specification to Proposed Recommendation.
Default Highlight: css
<pre class=link-defaults>
spec:css-color-4; type:property; text:color
spec:html; type:element; text:link
Things to go in level 4:
* Create some way to put these new conditional things on an @import.
* The @document rule (commented out, down below). -->
<h2 id="introduction">Introduction</h2>
<h3 id="context">Background</h3>
<em>This section is not normative.</em>
[[!CSS21]] defines one type of conditional group rule, the
''@media'' rule, and allows only style rules (not other @-rules)
inside of it. The ''@media'' rule provides the ability to
have media-specific style sheets, which is also provided by style
sheet linking features such as ''@import'' and
<{link}>. The restrictions on the contents of
''@media'' rules made them less useful; they have forced authors
using CSS features involving @-rules in media-specific style sheets to
use separate style sheets for each medium.
This specification extends the rules for the contents of
conditional group rules to allow other @-rules, which enables authors
to combine CSS features involving @-rules with media specific style
sheets within a single style sheet.
This specification also defines an additional type of conditional
group rule, ''@supports'', to
address author and user requirements.
The ''@supports'' rule allows CSS to be conditioned on
implementation support for CSS properties and values. This rule makes
it much easier for authors to use new CSS features and provide good
fallback for implementations that do not support those features. This
is particularly important for CSS features that provide new layout
mechanisms, and for other cases where a set of related styles needs to
be conditioned on property support.
<h3 id="placement">Module Interactions</h3>
This module replaces and extends the ''@media'' rule
feature defined in [[!CSS21]] section 7.2.1 and
incorporates the modifications previously made non-normatively by
[[!MEDIAQUERIES-4]] section 1.
<h2 id="processing">Processing of conditional group rules</h2>
This specification defines some CSS [=at-rules=],
called <dfn export lt="conditional group rule">conditional group rules</dfn>,
that associate a condition with a group of other
CSS rules. These different rules allow testing different types of
conditions, but share common behavior for how their contents are used
when the condition is true and when the condition is false.
<div class="example">
For example, this rule:
@media print {
/* hide navigation controls when printing */
#navigation { display: none }
causes a particular CSS rule
(making elements with ID &ldquo;navigation&rdquo; be display:none)
apply only when the style sheet is used for a print medium.
Each conditional group rule has a condition, which at any time
evaluates to true or false. When the condition is true, CSS processors
<strong>must</strong> apply the rules inside the group rule as though
they were at the group rule's location; when the condition is false, CSS
processors <strong>must not</strong> apply any of rules inside the group
rule. The current state of the condition does not affect the CSS object
model, in which the contents of the group rule always remain within the
group rule.
This means that when multiple conditional group rules are nested,
a rule inside of both of them applies only when all of the rules'
conditions are true.
<div class="example">For example, with this set of nested rules:
@media print { // rule (1)
/* hide navigation controls when printing */
#navigation { display: none }
@media (max-width: 12cm) { // rule (2)
/* keep notes in flow when printing to narrow pages */
.note { float: none }
the condition of the rule marked (1) is true for print media, and the
condition of the rule marked (2) is true when the width of the display
area (which for print media is the page box) is less than or equal to
12cm. Thus the rule ''#navigation { display: none }'' applies
whenever this style sheet is applied to print media, and the rule
''.note { float: none }'' is applied only when the style sheet
is applied to print media <em>and</em> the width of the page box is less
than or equal to 12 centimeters.</div>
When the condition for a conditional group rule changes, CSS
processors <strong>must</strong> reflect that the rules now apply or no
longer apply, except for properties whose definitions define effects of
computed values that persist past the lifetime of that value (such as
for some properties in [[CSS3-TRANSITIONS]] and
<h2 id="contents-of">
Contents of conditional group rules</h2>
All [=conditional rules=] are defined to take a <<stylesheet>> in their block,
which means they can accept any rule that is normally allowed at the top-level of a stylesheet,
and not otherwise restricted.
(For example, an ''@import'' rule must appear at the actual beginning of a stylesheet,
and so is not valid inside of another rule.)
Invalid or unknown rules inside the <<stylesheet>> must be considered invalid and ignored,
but do not invalidate the [=conditional rule=].
<h2 id="use">
Placement of conditional group rules</h2>
Conditional group rules are allowed at the top-level of a style
sheet, and inside other conditional group rules. CSS processors
<strong>must</strong> process such rules as <a
href="#processing">described above</a>.
Any rules that are not allowed after a style rule (e.g., ''@charset'',
''@import'', or ''@namespace'' rules) are also not allowed after a
conditional group rule. Therefore, style sheets <strong>must
not</strong> place such rules after a conditional group rules, and CSS
processors <strong>must</strong> ignore such rules.
<h2 id="at-media">
Media-specific style sheets: the ''@media'' rule</h2>
The <dfn at-rule id="at-ruledef-media">@media</dfn> rule
is a conditional group rule whose condition is a media query.
Its syntax is:
<pre class="prod def" nohighlight>
@media <<media-query-list>> {
It consists of the at-keyword ''@media''
followed by a (possibly empty) media query list
(as defined in [[!MEDIAQUERIES-4]]),
followed by a block containing arbitrary rules.
The condition of the rule is the result of the media query.
<div class="example">
This ''@media'' rule:
@media screen and (min-width: 35em),
print and (min-width: 40em) {
#section_navigation { float: left; width: 10em; }
has the condition
''screen and (min-width: 35em), print and (min-width: 40em)'',
which is true for screen displays
whose viewport is at least 35 times the initial font size
and for print displays
whose viewport is at least 40 times the initial font size.
When either of these is true,
the condition of the rule is true,
and the rule
''#section_navigation { float: left; width: 10em; }''
is applied.
<h2 id="at-supports">Feature queries: the ''@supports'' rule</h2>
The <dfn at-rule id="at-ruledef-supports">@supports</dfn> rule is a conditional group
rule whose condition tests whether the user agent supports CSS
property:value pairs. Authors can use it to write style sheets that use
new features when available but degrade gracefully when those features
are not supported. CSS has existing mechanisms for graceful
degradation, such as ignoring unsupported properties or values, but
these are not always sufficient when large groups of styles need to be
tied to the support for certain features, as is the case for use of new
layout system features.
The syntax of the condition in the ''@supports'' rule
is similar to that defined for <<media-condition>> in [[MEDIAQUERIES-4]]:
* negation is needed so that
the new-feature styles and the fallback styles
can be separated
(within the forward-compatible grammar's rules for the syntax of @-rules),
and not required to override each other.
* conjunction (and) is needed so that
multiple required features can be tested.
* disjunction (or) is needed
when there are multiple alternative features for a set of styles,
particularly when some of those alternatives are vendor-prefixed properties or values.
* "unknown" values (neither true nor false) are needed
to allow for future-compatibility,
so new types of support queries can be added
and treated sensibly in older UAs.
Therefore, the syntax of the ''@supports'' rule allows
testing for property:value pairs, and arbitrary conjunctions (and),
disjunctions (or), and negations (not) of them.
The syntax of the ''@supports'' rule is:
<pre class="prod def" nohighlight>
@supports <<supports-condition>> {
with <<supports-condition>> defined as:
<pre class="prod def" nohighlight>
<dfn>&lt;supports-condition></dfn> = not <<supports-in-parens>>
| <<supports-in-parens>> [ and <<supports-in-parens>> ]*
| <<supports-in-parens>> [ or <<supports-in-parens>> ]*
<dfn>&lt;supports-in-parens></dfn> = ( <<supports-condition>> ) | <<supports-feature>> | <<general-enclosed>>
<dfn>&lt;supports-feature></dfn> = <<supports-decl>>
<dfn>&lt;supports-decl></dfn> = ( <<declaration>> )
The above grammar is purposely very loose for forwards-compatibility reasons,
since the <<general-enclosed>> production
allows for substantial future extensibility.
Any ''@supports'' rule that does not parse according to the grammar above
(that is, a rule that does not match this loose grammar
which includes the <<general-enclosed>> production)
is invalid.
Style sheets <strong>must not</strong> use such a rule and
processors <strong>must</strong> ignore such a rule (including all of its contents).
Each of these grammar terms is associated with a boolean result,
as follows:
: <<supports-condition>>
: <<supports-in-parens>>
:: The result is the result of the child subexpression.
: not <<supports-in-parens>>
:: The result is the negation of the <<supports-in-parens>> term.
The negation of unknown is unknown.
: <<supports-in-parens>> [ and <<supports-in-parens>> ]*
The result is true if all of the <<supports-in-parens>> child terms are true,
false if at least one of the <<supports-in-parens>> is false,
and unknown otherwise.
: <<supports-in-parens>> [ or <<supports-in-parens>> ]*
The result is false if all of the <<supports-in-parens>> child terms are false,
true if at least one of the <<supports-in-parens>> is true,
and unknown otherwise.
: <<supports-decl>>
The result is true if the UA [=supports=] the declaration within the parentheses.
: <<general-enclosed>>
The result is unknown.
Authors must not use <<general-enclosed>> in their stylesheets.
<span class='note'>It exists only for future-compatibility,
so that new syntax additions do not invalidate too much of a <<supports-condition>> in older user agents.</span>
The condition of the ''@supports'' rule
is the result of the <<supports-condition>> in its prelude.
<div class="example">
For example, the following rule
@supports ( display: flex ) {
body, #navigation, #content { display: flex; }
#navigation { background: blue; color: white; }
#article { background: white; color: black; }
applies the rules inside the ''@supports'' rule only when
''display: flex'' is supported.
<div class="example">
The following example shows an additional ''@supports'' rule that can
be used to provide an alternative for when ''display: flex'' is not
@supports not ( display: flex ) {
body { width: 100%; height: 100%; background: white; color: black; }
#navigation { width: 25%; }
#article { width: 75%; }
Note that the 'width' declarations may be harmful to the
flex-based layout, so it is important that they be present only in
the non-flex styles.
<div class="example">
The following example checks for support for the 'box-shadow'
property, including checking for support for vendor-prefixed versions of
it. When the support is present, it specifies both 'box-shadow' (with
the prefixed versions) and 'border' in a way what would cause the box to
become invisible were 'box-shadow' not supported.
.noticebox {
border: 1px solid black;
padding: 1px;
@supports ( box-shadow: 0 0 2px black inset ) or
( -moz-box-shadow: 0 0 2px black inset ) or
( -webkit-box-shadow: 0 0 2px black inset ) or
( -o-box-shadow: 0 0 2px black inset ) {
.noticebox {
-moz-box-shadow: 0 0 2px black inset;
-webkit-box-shadow: 0 0 2px black inset;
-o-box-shadow: 0 0 2px black inset;
box-shadow: 0 0 2px black inset; /* unprefixed last */
/* override the rule above the @supports rule */
border: none;
padding: 2px;
To avoid confusion between <css>and</css> and <css>or</css>, the syntax requires
that both <css>and</css> and <css>or</css> be specified explicitly (rather than, say,
using commas or spaces for one of them). Likewise, to avoid confusion
caused by precedence rules, the syntax does not allow <css>and</css>, <css>or</css>,
and <css>not</css> operators to be mixed without a layer of parentheses.
<div class="example">
For example, the following rule is not valid:
<pre class="illegal">
@supports (transition-property: color) or
(animation-name: foo) and
(transform: rotate(10deg)) {
// ...
Instead, authors must write one of the following:
@supports ((transition-property: color) or
(animation-name: foo)) and
(transform: rotate(10deg)) {
// ...
@supports (transition-property: color) or
((animation-name: foo) and
(transform: rotate(10deg))) {
// ...
The declaration being tested must always occur within parentheses,
when it is the only thing in the expression.
<div class="example">
For example, the following rule is not valid:
<pre class="illegal">
@supports display: flex {
// ...
Instead, authors must write:
@supports (display: flex) {
// ...
The syntax allows extra parentheses when they are not needed. This
flexibility is sometimes useful for authors (for example, when
commenting out parts of an expression) and may also be useful for
authoring tools.
<div class="example">
For example, authors may write:
@supports ((display: flex)) {
// ...
A trailing ''!important'' on a declaration being tested is allowed,
though it won't change the validity of the declaration.
<div class="example">
For example, the following rule is valid:
@supports (display: flex !important) {
// ...
<h3 id="support-definition">Definition of support</h3>
For forward-compatibility,
<a href="">section 4.1.8
(Declarations and properties)</a> of [[!CSS21]]
defines rules for handling invalid properties and values.
CSS processors that
do not implement or partially implement a specification
<strong>must</strong> treat any part of a value that they
do not implement, or
do not have a usable level of support for,
as invalid according to this rule
for handling invalid properties and values,
and therefore <strong>must</strong> discard the declaration as a parse error.
A CSS processor is considered to <dfn export for=CSS id="dfn-support">support</dfn>
a declaration (consisting of a property and value) if it accepts that
declaration (rather than discarding it as a parse error).
If a processor does not implement, with a usable level of support,
the value given,
then it <strong>must not</strong>
accept the declaration or claim support for it.
Note: Note that properties or values
whose support is effectively disabled by user preferences
are still considered as supported by this definition.
For example, if a user has enabled a high-contrast mode
that causes colors to be overridden,
the CSS processor is still considered to support the 'color' property
even though declarations of the 'color' property may have no effect.
On the other hand, a developer-facing preference
whose purpose is to enable or disable support for an experimental CSS feature
does affect this definition of support.
These rules (and the equivalence between them) allow
authors to use fallback (either in the [[CSS1]] sense of declarations
that are overridden by later declarations or with the new capabilities
provided by the ''@supports'' rule in this specification) that works
correctly for the features implemented. This applies especially to
compound values; implementations must implement all parts of the value
in order to consider the declaration supported, either inside a style rule
or in the declaration condition of an ''@supports'' rule.
<h2 id="at-document">Document queries: the ''@document'' rule</h2>
The <dfn>@document</dfn> rule is a conditional group
rule whose condition depends on the
<a href="#url-of-doc">URL of the document being styled</a>.
This allows style sheets, particularly user style sheets, to have styles
that only apply to a set of pages rather than to all pages using the
style sheet.
Issue: Given that this @-rule is intended primarily for user
style sheets, what should this specification say about its use in author
style sheets? Should it be forbidden? Should use instead be
discouraged? Or should this specification remain neutral on the
topic, since there are valid uses in author style sheets?
<p id="url-of-doc">The <dfn>URL of the document being styled</dfn> is
the URI at which the document is located, excluding any fragment
identifiers. (This means, for example, that HTTP redirects have been
followed.) If the styles are being applied inside a complete document
embedded into the presentation of another (e.g., [[HTML5]]&#39;s <code
class="html">iframe</code>, <code class="html">object</code>, or <code
class="html">img</code> elements), the relevant URI is that of the
frame, not of its container. However, if content from other documents
is mixed in via mechanisms that mix content from one document into
another (e.g., [[SVG11]]&#39;s <code>use</code> element), then the
address of the container document is used.
Note: In [[HTML5]], this is the
<a href="">document's address</a>
of a document in a
<a href="">browsing context</a>.
<div class="issue">What form of normalization is done on URLs and domains
before matching? In particular, this specification needs to describe:
<li>what form is used for the <a href="#url-of-doc">URL of the document
being styled</a> (and what has been normalized in that form)
<li>what normalization (if any) happens to the argument of each of the match
functions before the comparison that they describe and
<li>whether the
comparison algorithm used is string comparison or some other URL
comparison algorithm.</ul></div>
The ''@document'' rule's condition is written as a
comma-separated list of <dfn>URL matching functions</dfn>, and the
condition evaluates to true whenever any one of those functions
evaluates to true. The following URL matching functions are
<dt><dfn id="url-exact" title="url()|URL matching functions::exact">&lt;url&gt;</dfn>
The 'url()' function is the <dfn>exact url matching
function</dfn>. It evaluates to true whenever the <a
href="#url-of-doc">URL of the document being styled</a> is exactly
the URL given.
Note: The 'url()' function, since it is a core syntax
element in CSS, is allowed (subject to different character
limitations and thus escaping requirements) to contain an unquoted
value (in addition to the string values that are allowed as
arguments for all four functions).
<div class="example">
For example, this rule:
@document url("") {
#summary { background: yellow; color: black}
styles the <code class="html">summary</code> element on the page
<code></code>, but not on any other
<dt><dfn id="url-prefix" title="url-prefix()|URL matching functions::prefix">url-prefix(&lt;string&gt;)</dfn>
The 'url-prefix()' function is the <dfn>url prefix
matching function</dfn>. It evaluates to true whenever the
<a href="#url-of-doc">URL of the document being styled</a>
has the argument to the function as an
initial substring (which is true when the two strings are equal).
When the argument is the empty string, it evaluates to true for all
<div class="example">
For example, this rule:
@document url-prefix("") {
#summary { background: yellow; color: black}
styles the <code class="html">summary</code> element on the page
<code></code> and on the page
<code></code>, but it does not
affect the page <code></code> or the page
<dt><dfn id="url-domain" title="domain()|URL matching functions::domain">domain(&lt;string&gt;)</dfn>
The 'domain()' function is the <dfn>domain
matching function</dfn>. It evaluates to true whenever
the <a href="#url-of-doc">URL of the document being styled</a>
has a host subcomponent (as defined in [[!URI]])
and that host subcomponent is exactly the argument to the
'domain()' function or a final substring of the host
component is a period (U+002E) immediately followed by the argument
to the 'domain()' function.
<div class="example">
For example, this rule:
@document domain("") {
body { font-size: 16px ! important }
changes the font size of the body element for pages such as
<code></code> and
<code></code> and
but it does not affect the page
<dt><dfn id="url-regexp" title="regexp()|URL matching functions::regular expression">regexp(&lt;string&gt;)</dfn>
The contents of the &lt;string&gt; argument <strong>must</strong>
match the JavaScript <code>Pattern</code> production
([[!ECMA-262-5.1]], section 15.10.1). However,
failing to do so is not a CSS syntax error and does not trigger any
error handling for CSS syntax errors.
The ''regexp()'' function evaluates to true whenever the string
argument compiled as a JavaScript regular expression with the
<code>global</code>, <code>ignoreCase</code> and
<code>multiline</code> flags <em>disabled</em>
(see [[!ECMA-262-5.1]], sections through
compiles successfully and the resulting regular expression matches
the entirety of the
<a href="#url-of-doc">URL of the document being styled</a>.
Note: Note that regular expression must match the entire
URL, not just a part of it.
Note: Note that this definition intentionally matches the
behavior of the <a
href=""><code class="html">pattern</code>
attribute</a> on the <code class="html">input</code> element
in [[HTML5]].
<div class="example">
For example, this rule:
@document regexp("\\d{4}/[^/]*-CSS2-\\d{8}/") {
body { font-size: 20px ! important }
changes the font size of the body element for pages such as
Note: Note that the backslashes in the regular
expression require CSS escaping as ''\\''.
Implementations <strong>must</strong> treat any unknown URL matching
functions as a syntax error, and thus ignore the ''@document'' rule.
<span class="issue">Should we instead have more complicated error
handling rules to make forward-compatibility work differently, or is
this rule the best solution for such future expansion anyway?</span>
<div class="issue">This syntax doesn't offer any ability to do negations,
which has been requested in <a
href="">Mozilla bug
349813</a>. Use cases that people have wanted negations for
<li>User style sheets that want a particular rule in general, but know
that that rule does more harm than good on specific sites.
<li>Authors who have a rule that they want to apply to most of their
pages, but wish to make a few exceptions for.
This extends the lexical scanner in the
<a href="">Grammar of CSS 2.1</a>
([[!CSS21]], Appendix G) by adding:
<pre>@{D}{O}{C}{U}{M}{E}{N}{T} {return DOCUMENT_SYM;}</pre>
and the grammar by adding
: DOCUMENT_SYM S+ <a>url_match_fn</a> ( "," S* <a>url_match_fn</a> )* <a>group_rule_body</a>
<h2 id="apis">APIs</h2>
<h3 id='extentions-to-cssrule-interface'>
Extensions to the <code>CSSRule</code> interface</h3>
The <code>CSSRule</code> interface is extended as follows:
<pre class='idl'>
partial interface CSSRule {
const unsigned short SUPPORTS_RULE = 12;
const unsigned short DOCUMENT_RULE = 13;
<h3 id='the-cssgroupingrule-interface'>
The <code>CSSGroupingRule</code> interface</h3>
The {{CSSGroupingRule}} interface represents an at-rule that contains other rules nested inside itself.
<pre class='idl'>
interface CSSGroupingRule : CSSRule {
readonly attribute <a href="">CSSRuleList</a> cssRules;
unsigned long insertRule (CSSOMString rule, unsigned long index);
void deleteRule (unsigned long index);
<dl class='idl-attributes'>
<dt><code>cssRules</code> of type <code><a href="">CSSRuleList</a></code>, readonly
<dd>The <code>cssRules</code> attribute must return a <code>CSSRuleList</code>
object for the list of CSS rules nested inside the grouping rule.
<dl class='idl-methods'>
<dt><code>insertRule(CSSOMString rule, unsigned long index)</code>, returns
<code>unsigned long</code>
The <code>insertRule</code> operation must
insert a CSS rule <var>rule</var>
into the CSS rule list returned by <code>cssRules</code>,
such that the inserted rule will be at position <var>index</var>,
and any rules previously at <var>index</var> or higher
will increase their index by one.
It must throw INDEX_SIZE_ERR
if index is greater than <code>cssRules.length</code>.
It must throw SYNTAX_ERR
if <var>rule</var> has a syntax error and is unparseable;
this does not include syntax errors handled by error handling rules
for constructs inside of the rule,
but this does include cases where the string given
does not parse into a single CSS rule (such as when the string is empty)
or where there is anything other than whitespace or comments
after that single CSS rule.
if the rule cannot be inserted at the location specified,
for example, if an ''@import'' rule is inserted inside a group rule.
The return value is the <var>index</var> parameter.
<dt><code>deleteRule (unsigned long index)</code>, return <code>void</code>
The <code>deleteRule</code> operation must
remove a CSS rule from
the CSS rule list returned by <code>cssRules</code> at <var>index</var>.
It must throw INDEX_SIZE_ERR
if index is greater than or equal to <code>cssRules.length</code>.
<h3 id="the-cssconditionrule-interface">
The <code>CSSConditionRule</code> interface</h3>
The {{CSSConditionRule}} interface represents
all the &ldquo;conditional&rdquo; at-rules,
which consist of a condition and a statement block.
<pre class='idl' export>
interface CSSConditionRule : CSSGroupingRule {
attribute CSSOMString conditionText;
<dl class='idl-attributes'>
<dt><code>conditionText</code> of type <code>CSSOMString</code>
The <code>conditionText</code> attribute represents
the condition of the rule.
Since what this condition does
varies between the derived interfaces of <code>CSSConditionRule</code>,
those derived interfaces
may specify different behavior for this attribute
(see, for example, <code>CSSMediaRule</code> below).
In the absence of such rule-specific behavior,
the following rules apply:
The <code>conditionText</code> attribute, on getting, must return
the result of serializing the associated condition.
On setting the <code>conditionText</code> attribute these steps
must be run:
<li>Trim the given value of white space.
<li>If the given value matches the grammar of the
appropriate condition production for the given rule,
replace the associated CSS condition with the given value.
<li>Otherwise, do nothing.
<h3 id="the-cssmediarule-interface">
The <code>CSSMediaRule</code> interface</h3>
The {{CSSMediaRule}} interface represents a ''@media'' at-rule:
<pre class='idl'>
interface CSSMediaRule : CSSConditionRule {
[SameObject, PutForwards=mediaText] readonly attribute MediaList media;
<dl class='idl-attributes'>
<dt><code>media</code> of type {{MediaList}}, readonly
<dd>The <code>media</code> attribute must return a {{MediaList}} object
for the list of media queries specified with the ''@media'' at-rule.
<dt><code>conditionText</code> of type <code>CSSOMString</code> (CSSMediaRule-specific definition for attribute on CSSConditionRule)
<dd>The <code>conditionText</code> attribute (defined on the <code>CSSConditionRule</code> parent rule),
on getting, must return the value of <code>media.mediaText</code> on the rule.
Setting the <code>conditionText</code> attribute
must set the <code>media.mediaText</code> attribute on the rule.
<h3 id="the-csssupportsrule-interface">
The <code>CSSSupportsRule</code> interface</h3>
The {{CSSSupportsRule}} interface represents a ''@supports'' rule.
<pre class='idl'>
interface CSSSupportsRule : CSSConditionRule {
<dl class='idl-attributes'>
<dt><code>conditionText</code> of type <code>CSSOMString</code> (CSSSupportsRule-specific definition for attribute on CSSConditionRule)
<dd>The <code>conditionText</code> attribute (defined on the <code>CSSConditionRule</code> parent rule),
on getting, must return the condition that was specified,
without any logical simplifications,
so that the returned condition will evaluate to the same result
as the specified condition
in any conformant implementation of this specification
(including implementations that implement future extensions
allowed by the <<general-enclosed>> exensibility mechanism in this specification).
In other words,
token stream simplifications are allowed
(such as reducing whitespace to a single space
or omitting it in cases where it is known to be optional),
but logical simplifications (such as removal of unneeded parentheses,
or simplification based on evaluating results) are not allowed.
<h3 id="the-cssdocumentrule-interface">
The <code>CSSDocumentRule</code> interface</h3>
The {{CSSDocumentRule}} interface represents a ''@document'' rule.
<pre class='idl'>
interface CSSDocumentRule : CSSConditionRule {
<h3 id='the-css-namespace'>
<span id='the-css-interface'>The <code>CSS</code> namespace, and the <code title=''>supports()</code> function</span></h3>
The {{CSS}} namespace holds useful CSS-related functions that do not belong elsewhere.
<pre class='idl'>
partial namespace CSS {
boolean supports(CSSOMString property, CSSOMString value);
boolean supports(CSSOMString conditionText);
<dl class='idl-methods'>
<dt><code>supports(CSSOMString property, CSSOMString value)</code>, returns <code>boolean</code>
<dt><code>supports(CSSOMString conditionText)</code>, returns <code>boolean</code>
When the {{supports(property, value)}} method is invoked
with two arguments <var>property</var> and <var>value</var>,
it must return <code>true</code> if <var>property</var> is a literal match for the name of a CSS property that the UA supports,
and <var>value</var> would be successfully parsed as a supported value for that property.
(Literal match means that no CSS escape processing is performed,
and leading and trailing whitespace are not stripped,
so any leading whitespace, trailing whitespace,
or CSS escapes equivalent to the name of a property
would cause the method to return <code>false</code>.)
Otherwise, it must return <code>false</code>.
When {{supports(conditionText)}} invoked with a single <var>conditionText</var> argument,
it must return <code>true</code> if <var>conditionText</var>,
when either parsed and evaluated as a <<supports-condition>>
or parsed as a <<declaration>>,
wrapped in implied parentheses,
and evaluated as a <<supports-condition>>,
would return true.
Otherwise, it must return <code>false</code>.
<h2 class=no-num id=priv-sec>Privacy and Security Considerations</h2>
This spec introduces no new security considerations.
Various features in this specification,
associated mainly with the ''@media'' rule
but also to some degree with the ''@supports'' rule,
provide information to Web content about
the user's hardware and software and their configuration and state.
Most of the information is provided through the features in [[MEDIAQUERIES-4]]
rather than through the features in this specification.
However, the ''@supports'' rule may provide some additional details about the user's software
and whether it is running with non-default settings that may enable or disable certain features.
Most of this information can also be determined through other APIs.
However, the features in this specification are one of the ways this information
is exposed on the Web.
This information can also, in aggregate, be used to improve the accuracy of
<a href="">fingerprinting</a> of the user.
<h2 id="changes">
The following (non-editorial) changes were made to this specification since the
<a href="">4 April 2013 Candidate Recommendation</a>:
<li>Drop requirement for spaces around ''and'', ''or'', and ''not'' keywords
for consistency with <a href="">Media Queries</a>
(which are themselves constrained by compatibility with the output of some CSS minimizers
that rely on some of the more arcane aspects of CSS tokenization).
Note that white space--or a comment--is still required <em>after</em> these keywords,
since without it they and the ensuing opening parenthesis will be tokenized as a function opening token.
<li>Allow the <code title=''>supports()</code> method
to imply parentheses for simple declarations,
for consistency with the ''@import'' rule’s ''supports()'' function.
<li>Fixed missing semicolons in IDL code.
<li>Updated links, terminology, and example code in response to changes to other modules.
<li>Added section on privacy and security considerations.
<h2 class=no-num id="acknowledgments">Acknowledgments</h2>
Thanks to the ideas and feedback from
Tab Atkins,
Arthur Barstow,
Ben Callahan,
<span lang="tr">Tantek Çelik</span>,
Alex Danilo,
Elika Etemad,
Pascal Germroth,
<span lang="de">Björn Höhrmann</span>,
Paul Irish,
Brad Kemper,
<span lang="nl">Anne van Kesteren</span>,
Vitor Menezes,
Alex Mogilevsky,
Chris Moschini,
James Nurthen,
Simon Pieters,
<span lang="fr">Florian Rivoal</span>,
<span lang="fr">Simon Sapin</span>,
Nicholas Shanks,
Ben Ward,
Zack Weinberg,
Estelle Weyl,
Boris Zbarsky,
and all the rest of the <a href="">www-style</a> community.