Wed, 13 Mar 2013 15:29:59 -0700
[css3-conditional] The editor's draft is not a last call.
1 <!DOCTYPE html public '-//W3C//DTD HTML 4.01//EN'
2 'http://www.w3.org/TR/html4/strict.dtd'>
3 <html lang="en">
4 <head profile="http://www.w3.org/2006/03/hcard">
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>CSS Conditional Rules Module Level 3</title>
7 <link rel="stylesheet" type="text/css" href="../default.css">
8 <link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
9 <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
10 <!--
11 <script src="http://test.csswg.org/harness/annotate.js#CSS3-CONDITIONAL_DEV"
12 type="text/javascript" defer></script
13 -->
14 </head>
15 <body class="h-entry">
17 <div class="head">
18 <!--logo-->
20 <h1 class="p-name">CSS Conditional Rules Module Level 3</h1>
22 <h2 class="no-num no-toc">[LONGSTATUS] <span class="dt-updated"><span class="value-title" title="[CDATE]">[DATE]</span></span></h2>
23 <dl>
24 <dt>This version:
25 <dd><a class="u-url" href="[VERSION]">
26 http://www.w3.org/TR/[YEAR]/ED-css3-conditional-[CDATE]/</a>
28 <dt>Latest version:
29 <dd><a href="http://www.w3.org/TR/[SHORTNAME]/">http://www.w3.org/TR/[SHORTNAME]/</a>
31 <dt>Editor's draft:
32 <dd><a href="http://dev.w3.org/csswg/[SHORTNAME]/">http://dev.w3.org/csswg/[SHORTNAME]/</a>
33 (<a href="https://dvcs.w3.org/hg/csswg/log/tip/[SHORTNAME]/Overview.src.html">change log</a>)
35 <dt>Previous version:
36 <dd><a rel="previous" href="http://www.w3.org/TR/2012/WD-css3-conditional-20121213/">http://www.w3.org/TR/2012/WD-css3-conditional-20121213/</a></dd>
38 <dt>Editors:
39 <dd class="p-author h-card vcard"><a class="p-name fn u-url url" rel="author" href="http://dbaron.org/">L. David Baron</a>,
40 <a class="p-org org h-org" href="http://www.mozilla.org/">Mozilla</a>
42 <dt>Issues list:
43 <dd>Maintained in document (only editor's draft is current)
45 <dt>Feedback:
47 <dd><a
48 href="http://lists.w3.org/Archives/Public/www-style/">www-style@w3.org</a>
49 with subject line “<kbd>[[SHORTNAME]] <var>… message topic
50 …</var></kbd>”
52 <dt>Test suite:
53 <dd><a href="https://test.csswg.org/shepherd/search/spec/css3-conditional/">submitted tests</a>,
54 <a href="https://test.csswg.org/harness/suite/CSS3-CONDITIONAL_DEV/">nightly test suite</a>
56 </dl>
58 <!--copyright-->
60 <hr title="Separator for header">
61 </div>
63 <h2 class="no-num no-toc" id="abstract">Abstract</h2>
65 <p>CSS is a language for describing the rendering of structured documents
66 (such as HTML and XML) on screen, on paper, in speech, etc.
67 <span class="p-summary">
68 This module
69 contains the features of CSS for conditional processing of parts of
70 style sheets, conditioned on capabilities of the processor or the
71 document the style sheet is being applied to.
72 It includes and extends the functionality of CSS level 2 [[!CSS21]],
73 which builds on CSS level 1 [[CSS1]].
74 The main extensions compared to level 2 are
75 allowing nesting of certain at-rules inside '@media',
76 and the addition of the '@supports'
77 rule for conditional processing.
78 </span>
80 <h2 class="no-num no-toc" id="status">Status of this document</h2>
82 <!--status-->
84 <p>The following features are at risk:
85 <ul>
86 <li>The inclusion of '@font-face' rules and
87 '@keyframes' rules as allowed within all of the @-rules in
88 this specification is at risk, though only because of the relative
89 rates of advancement of specifications. If this specification is able
90 to advance faster than one or both of the specifications defining
91 those rules, then the inclusion of those rules will move from this
92 specification to the specification defining those rules.</li>
94 <li>The addition of support for @-rules inside of conditional grouping
95 rules is at risk; if interoperable implementations are not found, it
96 may be removed to advance the other features in this specification to
97 Proposed Recommendation.</li>
99 <li>The '@supports' rule is at risk; if interoperable
100 implementations are not found, it may be removed to advance the other
101 features in this specification to Proposed Recommendation.</li>
102 </ul>
104 <!--
106 Things to go in level 4:
108 * Create some way to put these new conditional things on an @import.
109 * The @document rule (commented out, down below).
111 -->
113 <h2 class="no-num no-toc" id="contents">Table of contents</h2>
115 <!--toc-->
117 <h2 id="introduction">Introduction</h2>
119 <h3 id="context">Background</h3>
121 <p><em>This section is not normative.</em>
123 <p>[[!CSS21]] defines one type of conditional group rule, the
124 '@media' rule, and allows only rulesets (not other @-rules)
125 inside of it. The '@media' rule provides the ability to
126 have media-specific style sheets, which is also provided by style
127 sheet linking features such as '@import' and
128 <code class="html"><link></code>. The restrictions on the contents of
129 '@media' rules made them less useful; they have forced authors
130 using CSS features involving @-rules in media-specific style sheets to
131 use separate style sheets for each medium.</p>
133 <p>This specification extends the rules for the contents of
134 conditional group rules to allow other @-rules, which enables authors
135 to combine CSS features involving @-rules with media specific style
136 sheets within a single style sheet.</p>
138 <p>This specification also defines an additional type of conditional
139 group rule, '@supports', to
140 address author and user requirements.</p>
142 <p>The '@supports' rule allows CSS to be conditioned on
143 implementation support for CSS properties and values. This rule makes
144 it much easier for authors to use new CSS features and provide good
145 fallback for implementations that do not support those features. This
146 is particularly important for CSS features that provide new layout
147 mechanisms, and for other cases where a set of related styles needs to
148 be conditioned on property support.</p>
150 <h3 id="placement">Module Interactions</h3>
152 <p>This module replaces and extends the '@media' rule
153 feature defined in [[!CSS21]] section <var>7.2.1</var> and
154 incorporates the modifications previously made non-normatively by
155 [[!MEDIAQ]] section <var>1</var>.</p>
157 <p>Its current definition depends on @-rules defined in [[!CSS3-FONTS]]
158 and [[!CSS3-ANIMATIONS]], but that dependency is only on the
159 assumption that those modules will advance ahead of this one. If this
160 module advances faster, then the dependency will be reversed.</p>
162 <h3 id="conventions">Document Conventions</h3>
164 <p>Conformance requirements are expressed with a combination of
165 descriptive assertions and RFC 2119 terminology. The key words “MUST”,
166 “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
167 “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
168 document are to be interpreted as described in RFC 2119.
169 However, for readability, these words do not appear in all uppercase
170 letters in this specification.
172 <p>All of the text of this specification is normative except sections
173 explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
175 <p>Examples in this specification are introduced with the words “for example”
176 or are set apart from the normative text with
177 <code class="html">class="example"</code>, like this:
179 <div class="example">
180 <p>This is an example of an informative example.</p>
181 </div>
183 <p>Informative notes begin with the word “Note” and are set apart from the
184 normative text with <code class="html">class="note"</code>, like this:
186 <p class="note">Note, this is an informative note.</p>
188 <h2 id="processing">Processing of conditional group rules</h2>
190 <p>This specification defines some CSS @-rules, called <dfn>conditional
191 group rules</dfn>, that associate a condition with a group of other
192 CSS rules. These different rules allow testing different types of
193 conditions, but share common behavior for how their contents are used
194 when the condition is true and when the condition is false.</p>
196 <div class="example">
197 <p>For example, this rule:</p>
198 <pre>@media print {
199 /* hide navigation controls when printing */
200 #navigation { display: none }
201 }</pre>
202 <p>causes a particular CSS rule (making elements with ID "navigation" be
203 display:none) apply only when the style sheet is used for a print
204 medium.
205 </div>
207 <p>Each conditional group rule has a condition, which at any time
208 evaluates to true or false. When the condition is true, CSS processors
209 <strong>must</strong> apply the rules inside the group rule as though
210 they were at the group rule's location; when the condition is false, CSS
211 processors <strong>must not</strong> apply any of rules inside the group
212 rule. The current state of the condition does not affect the CSS object
213 model, in which the contents of the group rule always remain within the
214 group rule.</p>
216 <p>This means that when multiple conditional group rules are nested,
217 a rule inside of both of them applies only when all of the rules'
218 conditions are true.</p>
220 <div class="example">For example, with this set of nested rules:
221 <pre>@media print { // rule (1)
222 /* hide navigation controls when printing */
223 #navigation { display: none }
224 @media (max-width: 12cm) { // rule (2)
225 /* keep notes in flow when printing to narrow pages */
226 .note { float: none }
227 }
228 }</pre>
229 the condition of the rule marked (1) is true for print media, and the
230 condition of the rule marked (2) is true when the width of the display
231 area (which for print media is the page box) is less than or equal to
232 12cm. Thus the rule ''#navigation { display: none }'' applies
233 whenever this style sheet is applied to print media, and the rule
234 ''.note { float: none }'' is applied only when the style sheet
235 is applied to print media <em>and</em> the width of the page box is less
236 than or equal to 12 centimeters.</div>
238 <p>When the condition for a conditional group rule changes, CSS
239 processors <strong>must</strong> reflect that the rules now apply or no
240 longer apply, except for properties whose definitions define effects of
241 computed values that persist past the lifetime of that value (such as
242 for some properties in [[CSS3-TRANSITIONS]] and
243 [[!CSS3-ANIMATIONS]]).</p>
245 <h2 id="contents-of">Contents of conditional group rules</h2>
247 <p>The syntax of each conditional group rule consists of some syntax
248 specific to the type of rule followed by a <dfn>group rule body</dfn>,
249 which is a block (pair of braces) containing a sequence of rules.</p>
251 <p>A group rule body is allowed to contain rulesets and any @-rules that
252 are allowed at the top level of a style sheet before and after a
253 ruleset. This means that @-rules that must occur at the beginning of
254 the style sheet (such as '@charset', '@import',
255 and '@namespace' rules) are not allowed inside of conditional group
256 rules. Conditional group rules can be nested.</p>
258 <p>In terms of the grammar, this specification defines the following
259 productions for use in the grammar of conditional group rules:</p>
261 <pre><dfn>nested_statement</dfn>
262 : ruleset | <i>media</i> | page | font_face_rule | keyframes_rule |
263 <i>supports_rule</i>
264 ;
266 <dfn>group_rule_body</dfn>
267 : '{' S* <i>nested_statement</i>* '}' S*
268 ;</pre>
269 <p>
270 in which all the productions are defined in that grammar with the
271 exception of <code>font_face_rule</code>
272 defined in [[!CSS3-FONTS]], <code>keyframes_rule</code> defined in
273 [[!CSS3-ANIMATIONS]], and <code>media</code> and <code>supports_rule</code>
274 defined in this specification.</p>
276 <p>In general, future CSS specifications that add new @-rules that are
277 not forbidden to occur after some other types of rules should modify
278 this <code>nested_statement</code> production to keep the grammar
279 accurate.</p>
281 <p>Style sheets <strong>must not</strong> use rules other than the allowed ones inside
282 conditional group rules.</p>
284 <p>CSS processors <strong>must</strong> ignore rules that are not
285 allowed within a group rule, and <strong>must</strong> handle invalid
286 rules inside of group rules as described in <a
287 href="http://www.w3.org/TR/CSS21/syndata.html#parsing-errors">section
288 4.2 (Rules for handling parsing errors)</a>, <a
289 href="http://www.w3.org/TR/CSS21/syndata.html#at-rules">section 4.1.5
290 (At-rules)</a>, and <a
291 href="http://www.w3.org/TR/CSS21/syndata.html#rule-sets">section 4.1.7
292 (Rule sets, declaration blocks, and selectors)</a> of [[!CSS21]].</p>
294 <h2 id="use">Placement of conditional group rules</h2>
296 <p>Conditional group rules are allowed at the top-level of a style
297 sheet, and inside other conditional group rules. CSS processors
298 <strong>must</strong> process such rules as <a
299 href="#processing">described above</a>.</p>
301 <p>Any rules that are not allowed after a ruleset (e.g., ''@charset'',
302 ''@import'', or ''@namespace'' rules) are also not allowed after a
303 conditional group rule. Therefore, style sheets <strong>must
304 not</strong> place such rules after a conditional group rules, and CSS
305 processors <strong>must</strong> ignore such rules.</p>
307 <h2 id="at-media">Media-specific style sheets: the '@media' rule</h2>
309 <p>The <dfn>'@media' rule</dfn> is a conditional group rule whose
310 condition is a media query. It consists of the at-keyword
311 '@media' followed by a (possibly empty) media query list (as
312 defined in [[!MEDIAQ]]), followed by a group rule body. The condition
313 of the rule is the result of the media query.</p>
315 <div class="example">
316 <p>This '@media' rule:</p>
317 <pre>@media screen and (min-width: 35em),
318 print and (min-width: 40em) {
319 #section_navigation { float: left; width: 10em; }
320 }</pre>
321 <p>has the condition
322 ''screen and (min-width: 35em), print and (min-width: 40em)'',
323 which is true for screen displays
324 whose viewport is at least 35 times the initial font size
325 and for print displays
326 whose viewport is at least 40 times the initial font size.
327 When either of these is true,
328 the condition of the rule is true,
329 and the rule
330 ''#section_navigation { float: left; width: 10em; }''
331 is applied.</p>
332 </div>
334 <p>In terms of the grammar, this specification extends the
335 <code>media</code> production in the
336 <a href="http://www.w3.org/TR/CSS21/grammar.html">Grammar of CSS 2.1</a>
337 ([[!CSS21]], Appendix G) into:
338 <pre><dfn>media</dfn>
339 : MEDIA_SYM S* media_query_list <i>group_rule_body</i>
340 ;</pre>
341 <p>where the <code>group_rule_body</code> production is defined in this
342 specification, the <code>media_query_list</code> production is defined
343 in [[!MEDIAQ]], and the others are defined in the <a
344 href="http://www.w3.org/TR/CSS21/grammar.html">Grammar of CSS 2.1</a>
345 ([[!CSS21]], Appendix G).
347 <h2 id="at-supports">Feature queries: the '@supports' rule</h2>
349 <p>The <dfn>'@supports' rule</dfn> is a conditional group
350 rule whose condition tests whether the user agent supports CSS
351 property:value pairs. Authors can use it to write style sheets that use
352 new features when available but degrade gracefully when those features
353 are not supported. CSS has existing mechanisms for graceful
354 degradation, such as ignoring unsupported properties or values, but
355 these are not always sufficient when large groups of styles need to be
356 tied to the support for certain features, as is the case for use of new
357 layout system features.</p>
359 <p>The syntax of the condition in the '@supports' rule is
360 slightly more complicated than for the other conditional group rules
361 (though has some similarities to media queries) since:</p>
362 <ul>
363 <li>negation is needed so that the new-feature styles and the fallback
364 styles can be separated (within the forward-compatible grammar's rules
365 for the syntax of @-rules), and not required to override each other</li>
366 <li>conjunction (and) is needed so that multiple required features can
367 be tested</li>
368 <li>disjunction (or) is needed when there are multiple alternative
369 features for a set of styles, particularly when some of those
370 alternatives are vendor-prefixed properties or values</li>
371 </ul>
373 <p>Therefore, the syntax of the '@supports' rule allows
374 testing for property:value pairs, and arbitrary conjunctions (and),
375 disjunctions (or), and negations (not) of them.</p>
377 <p>This extends the lexical scanner in the
378 <a href="http://www.w3.org/TR/CSS21/grammar.html">Grammar of CSS 2.1</a>
379 ([[!CSS21]], Appendix G) by adding:
380 <pre>
381 @{S}{U}{P}{P}{O}{R}{T}{S} {return <dfn>SUPPORTS_SYM</dfn>;}
382 {O}{R} {return <dfn>OR</dfn>;}
383 </pre>
385 <p>This then extends the grammar in the
386 <a href="http://www.w3.org/TR/CSS21/grammar.html">Grammar of CSS 2.1</a>,
387 using the lexical scanner there, with the additions of
388 <code><a href="http://www.w3.org/TR/css3-mediaqueries/#syntax">AND</a></code> and
389 <code><a href="http://www.w3.org/TR/css3-mediaqueries/#syntax">NOT</a></code>
390 tokens defined in the Media Queries specification [[!MEDIAQ]]
391 and the <code>OR</code> and <code>SUPPORTS_SYM</code> tokens defined above,
392 and with
393 <code><a href="http://www.w3.org/TR/CSS21/syndata.html#tokenization">declaration</a></code>,
394 <code><a href="http://www.w3.org/TR/CSS21/syndata.html#tokenization">any</a></code>,
395 and <code><a href="http://www.w3.org/TR/CSS21/syndata.html#tokenization">unused</a></code>
396 productions
397 and the <code><a href="http://www.w3.org/TR/CSS21/syndata.html#tokenization">FUNCTION</a></code> token
398 taken from the core syntax of CSS defined in
399 <a href="http://www.w3.org/TR/CSS21/syndata.html#tokenization">section 4.1.1 (Tokenization)</a> of [[!CSS21]],
400 by adding:</p>
402 <pre><dfn>supports_rule</dfn>
403 : <i>SUPPORTS_SYM</i> <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>* <i>supports_condition</i> <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>* <i>group_rule_body</i>
404 ;
406 <dfn>supports_condition</dfn>
407 : <i>supports_negation</i> | <i>supports_conjunction</i> | <i>supports_disjunction</i> |
408 <i>supports_condition_in_parens</i>
409 ;
411 <dfn>supports_condition_in_parens</dfn>
412 : ( '(' <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>* <i>supports_condition</i> <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>* ')' ) | <i>supports_declaration_condition</i> |
413 <i>general_enclosed</i>
414 ;
416 <dfn>supports_negation</dfn>
417 : <a href="http://www.w3.org/TR/css3-mediaqueries/#syntax"><i>NOT</i></a> <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>+ <i>supports_condition_in_parens</i>
418 ;
420 <dfn>supports_conjunction</dfn>
421 : <i>supports_condition_in_parens</i> ( <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>+ <a href="http://www.w3.org/TR/css3-mediaqueries/#syntax"><i>AND</i></a> <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>+ <i>supports_condition_in_parens</i> )+
422 ;
424 <dfn>supports_disjunction</dfn>
425 : <i>supports_condition_in_parens</i> ( <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>+ <i>OR</i> <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>+ <i>supports_condition_in_parens</i> )+
426 ;
428 <dfn>supports_declaration_condition</dfn>
429 : '(' <a href="http://www.w3.org/TR/CSS21/grammar.html#scanner"><i>S</i></a>* <a href="http://www.w3.org/TR/CSS21/syndata.html#tokenization"><i>declaration</i></a> ')'
430 ;
432 <dfn>general_enclosed</dfn>
433 : ( <a href="http://www.w3.org/TR/CSS21/syndata.html#tokenization"><i>FUNCTION</i></a> | '(' ) ( <a href="http://www.w3.org/TR/CSS21/syndata.html#tokenization"><i>any</i></a> | <a href="http://www.w3.org/TR/CSS21/syndata.html#tokenization"><i>unused</i></a> )* ')'
434 ;
435 </pre>
437 <p>
438 Implementations <strong>must</strong> parse ''@supports'' rules
439 based on the above grammar,
440 and when interpreting the above grammar,
441 <strong>must</strong> match the production before an <code>|</code> operator
442 in preference to the one after it.
443 </p>
445 <p>
446 The above grammar is purposely very loose for forwards-compatibility reasons,
447 since the <code>general_enclosed</code> production
448 allows for substantial future extensibility.
449 Any ''@supports'' rule that does not parse according to the grammar above
450 (that is, a rule that does not match this loose grammar
451 which includes the <code>general_enclosed</code> production)
452 is invalid.
453 Style sheets <strong>must not</strong> use such a rule and
454 processors <strong>must</strong> ignore such a rule (including all of its contents).
456 <p>Each of these grammar terms is associated with a boolean result, as
457 follows:</p>
458 <dl>
459 <dt>supports_condition</dt>
460 <dd>
461 The result is the result of the single child term.
462 </dd>
464 <dt>supports_condition_in_parens</dt>
465 <dd>
466 The result is the result of the single <code>supports_condition</code>
467 or <code>supports_declaration_condition</code> child term.
468 </dd>
470 <dt>supports_negation</dt>
471 <dd>
472 The result is the <em>negation</em> of the result of the
473 <code>supports_condition_in_parens</code> child term.
474 </dd>
476 <dt>supports_conjunction</dt>
477 <dd>
478 The result is true if the result of <em>all</em> of the
479 <code>supports_condition_in_parens</code> child terms is true;
480 otherwise it is false.
481 </dd>
483 <dt>supports_disjunction</dt>
484 <dd>
485 The result is true if the result of <em>any</em> of the
486 <code>supports_condition_in_parens</code> child terms is true;
487 otherwise it is false.
488 </dd>
490 <dt>supports_declaration_condition</dt>
491 <dd>
492 The result is whether the CSS processor <a href="#support-definition">supports</a> the declaration
493 within the parentheses.
494 </dd>
496 <dt>general_enclosed</dt>
497 <dd>
498 The result is always false.
499 Additionally, style sheets <strong>must not</strong>
500 write ''@supports'' rules
501 that match this grammar production.
502 (In other words, this production exists only for future extensibility,
503 and is not part of the description of a valid style sheet
504 in this level of the specification.)
505 <span class="note">Note that future levels may define functions
506 or other parenthesized expressions that can evaluate to true.</span>
507 </dd>
508 </dl>
510 <p>The condition of the '@supports' rule is the result of the
511 <code>supports_condition</code> term that is a child of the
512 <code>supports_rule</code> term.</p>
514 <div class="example">
515 <p>For example, the following rule</p>
516 <pre>@supports ( display: flexbox ) {
517 body, #navigation, #content { display: flexbox; }
518 #navigation { background: blue; color: white; }
519 #article { background: white; color: black; }
520 }</pre>
521 <p>applies the rules inside the '@supports' rule only when
522 ''display: flexbox'' is supported.</p>
523 </div>
525 <div class="example">
526 <p>The following example shows an additional '@supports' rule that can
527 be used to provide an alternative for when ''display: flexbox'' is not
528 supported:</p>
529 <pre>@supports not ( display: flexbox ) {
530 body { width: 100%; height: 100%; background: white; color: black; }
531 #navigation { width: 25%; }
532 #article { width: 75%; }
533 }</pre>
534 <p>Note that the 'width' declarations may be harmful to the
535 flexbox-based layout, so it is important that they be present only in
536 the non-flexbox styles.</p>
537 </div>
539 <div class="example">
540 <p>The following example checks for support for the 'box-shadow'
541 property, including checking for support for vendor-prefixed versions of
542 it. When the support is present, it specifies both 'box-shadow' (with
543 the prefixed versions) and 'color' in a way what would cause the text to
544 become invisible were 'box-shadow' not supported.</p>
545 <pre>@supports ( box-shadow: 2px 2px 2px black ) or
546 ( -moz-box-shadow: 2px 2px 2px black ) or
547 ( -webkit-box-shadow: 2px 2px 2px black ) or
548 ( -o-box-shadow: 2px 2px 2px black ) {
549 .outline {
550 color: white;
551 -moz-box-shadow: 2px 2px 2px black;
552 -webkit-box-shadow: 2px 2px 2px black;
553 -o-box-shadow: 2px 2px 2px black;
554 box-shadow: 2px 2px 2px black; /* unprefixed last */
555 }
556 }</pre></div>
558 <p>To avoid confusion between ''and'' and ''or'', the syntax requires
559 that both ''and'' and ''or'' be specified explicitly (rather than, say,
560 using commas or spaces for one of them). Likewise, to avoid confusion
561 caused by precedence rules, the syntax does not allow ''and'', ''or'',
562 and ''not'' operators to be mixed without a layer of parentheses.</p>
564 <div class="example">
565 <p>For example, the following rule is not valid:
566 <pre class="illegal">@supports (transition-property: color) or
567 (animation-name: foo) and
568 (transform: rotate(10deg)) {
569 // ...
570 }</pre>
571 <p>Instead, authors must write one of the following:</p>
572 <pre>@supports ((transition-property: color) or
573 (animation-name: foo)) and
574 (transform: rotate(10deg)) {
575 // ...
576 }</pre>
577 <pre>@supports (transition-property: color) or
578 ((animation-name: foo) and
579 (transform: rotate(10deg))) {
580 // ...
581 }</pre>
582 </div>
584 <p>Furthermore, whitespace is required after a ''not'' and on both
585 sides of an ''and'' or ''or''.</p>
587 <p>The declaration being tested must always occur within parentheses,
588 when it is the only thing in the expression.<p>
590 <div class="example">
591 <p>For example, the following rule is not valid:
592 <pre class="illegal">@supports display: flexbox {
593 // ...
594 }</pre>
595 <p>Instead, authors must write:</p>
596 <pre>@supports (display: flexbox) {
597 // ...
598 }</pre>
599 </div>
601 <p>The syntax allows extra parentheses when they are not needed. This
602 flexibility is sometimes useful for authors (for example, when
603 commenting out parts of an expression) and may also be useful for
604 authoring tools.</p>
606 <div class="example">
607 <p>For example, authors may write:</p>
608 <pre>@supports ((display: flexbox)) {
609 // ...
610 }</pre>
611 </div>
613 <p>A trailing ''!important'' on a declaration being tested is allowed,
614 though it won't change the validity of the declaration.
616 <div class="example">
617 <p>For example, the following rule is valid:
618 <pre>@supports (display: flexbox !important) {
619 // ...
620 }</pre>
621 </div>
623 <h3 id="support-definition">Definition of support</h3>
625 <p>For forward-compatibility,
626 <a href="http://www.w3.org/TR/CSS21/syndata.html#declaration">section 4.1.8
627 (Declarations and properties)</a> of [[!CSS21]]
628 defines rules for handling invalid properties and values.
629 CSS processors that
630 do not implement or partially implement a specification
631 <strong>must</strong> treat any part of a value that they
632 do not implement, or
633 do not have a usable level of support for,
634 as invalid according to this rule
635 for handling invalid properties and values,
636 and therefore <strong>must</strong> discard the declaration as a parse error.</p>
638 <p>A CSS processor is considered to <dfn id="dfn-support">support</dfn>
639 a declaration (consisting of a property and value) if it accepts that
640 declaration (rather than discarding it as a parse error).
641 If a processor does not implement, with a usable level of support,
642 the value given,
643 then it <strong>must not</strong>
644 accept the declaration or claim support for it.</p>
646 <p class="note">Note that properties or values
647 whose support is effectively disabled by user preferences
648 are still considered as supported by this definition.
649 For example, if a user has enabled a high-contrast mode
650 that causes colors to be overridden,
651 the CSS processor is still considered to support the 'color' property
652 even though declarations of the 'color' property may have no effect.
653 On the other hand, a developer-facing preference
654 whose purpose is to enable or disable support for an experimental CSS feature
655 does affect this definition of support.</p>
657 <p>These rules (and the equivalence between them) allow
658 authors to use fallback (either in the [[CSS1]] sense of declarations
659 that are overridden by later declarations or with the new capabilities
660 provided by the ''@supports'' rule in this specification) that works
661 correctly for the features implemented. This applies especially to
662 compound values; implementations must implement all parts of the value
663 in order to consider the declaration supported, either inside a ruleset
664 or in the declaration condition of an ''@supports'' rule.</p>
666 <!--
667 <h2 id="at-document">Document queries: the '@document' rule</h2>
669 <p>The <dfn>'@document' rule</dfn> is a conditional group
670 rule whose condition depends on the
671 <a href="#url-of-doc">URL of the document being styled</a>.
672 This allows style sheets, particularly user style sheets, to have styles
673 that only apply to a set of pages rather than to all pages using the
674 style sheet.</p>
676 <p class="issue">Given that this @-rule is intended primarily for user
677 style sheets, what should this specification say about its use in author
678 style sheets? Should it be forbidden? Should use instead be
679 discouraged? Or should this specification remain neutral on the
680 topic, since there are valid uses in author style sheets?</p>
682 <p id="url-of-doc">The <dfn>URL of the document being styled</dfn> is
683 the URI at which the document is located, excluding any fragment
684 identifiers. (This means, for example, that HTTP redirects have been
685 followed.) If the styles are being applied inside a complete document
686 embedded into the presentation of another (e.g., [[HTML5]]'s <code
687 class="html">iframe</code>, <code class="html">object</code>, or <code
688 class="html">img</code> elements), the relevant URI is that of the
689 frame, not of its container. However, if content from other documents
690 is mixed in via mechanisms that mix content from one document into
691 another (e.g., [[SVG11]]'s <code>use</code> element), then the
692 address of the container document is used.</p>
694 <p class="note">Note: In [[HTML5]], this is the
695 <a href="http://dev.w3.org/html5/spec/dom.html#documents">document's address</a>
696 of a document in a
697 <a href="http://dev.w3.org/html5/spec/browsers.html#browsing-context">browsing context</a>.</p>
699 <div class="issue">What form of normalization is done on URLs and domains
700 before matching? In particular, this specification needs to describe:
701 <ul>
702 <li>what form is used for the <a href="#url-of-doc">URL of the document
703 being styled</a> (and what has been normalized in that form)</li>
704 <li>what normalization (if any) happens to the argument of each of the match
705 functions before the comparison that they describe and</li>
706 <li>whether the
707 comparison algorithm used is string comparison or some other URL
708 comparison algorithm.</li></ul></div>
710 <p>The '@document' rule's condition is written as a
711 comma-separated list of <dfn>URL matching functions</dfn>, and the
712 condition evaluates to true whenever any one of those functions
713 evaluates to true. The following URL matching functions are
714 permitted:</p>
716 <dl>
717 <dt><dfn id="url-exact" title="url()|URL matching functions::exact"><url></dfn></dt>
719 <dd>
720 <p>The 'url()' function is the <dfn>exact url matching
721 function</dfn>. It evaluates to true whenever the <a
722 href="#url-of-doc">URL of the document being styled</a> is exactly
723 the URL given.</p>
725 <p class="Note">The 'url()' function, since it is a core syntax
726 element in CSS, is allowed (subject to different character
727 limitations and thus escaping requirements) to contain an unquoted
728 value (in addition to the string values that are allowed as
729 arguments for all four functions).</p>
731 <div class="example">
732 <p>For example, this rule:</p>
733 <pre>@document url("http://www.w3.org/Style/CSS/") {
734 #summary { background: yellow; color: black}
735 }</pre>
736 <p>styles the <code class="html">summary</code> element on the page
737 <code>http://www.w3.org/Style/CSS/</code>, but not on any other
738 pages.</p>
739 </div>
740 </dd>
742 <dt><dfn id="url-prefix" title="url-prefix()|URL matching functions::prefix">url-prefix(<string>)</dfn></dt>
744 <dd>
745 <p>The 'url-prefix()' function is the <dfn>url prefix
746 matching function</dfn>. It evaluates to true whenever the
747 <a href="#url-of-doc">URL of the document being styled</a>
748 has the argument to the function as an
749 initial substring (which is true when the two strings are equal).
750 When the argument is the empty string, it evaluates to true for all
751 documents.</p>
752 <div class="example">
753 <p>For example, this rule:</p>
754 <pre>@document url-prefix("http://www.w3.org/Style/CSS/") {
755 #summary { background: yellow; color: black}
756 }</pre>
757 <p>styles the <code class="html">summary</code> element on the page
758 <code>http://www.w3.org/Style/CSS/</code> and on the page
759 <code>http://www.w3.org/Style/CSS/Test</code>, but it does not
760 affect the page <code>http://www.w3.org/</code> or the page
761 <code>http://www.example.com/Style/CSS/</code>.</p>
762 </div>
763 </dd>
765 <dt><dfn id="url-domain" title="domain()|URL matching functions::domain">domain(<string>)</dfn></dt>
767 <dd>
768 <p>The 'domain()' function is the <dfn>domain
769 matching function</dfn>. It evaluates to true whenever
770 the <a href="#url-of-doc">URL of the document being styled</a>
771 has a host subcomponent (as defined in [[!URI]])
772 and that host subcomponent is exactly the argument to the
773 'domain()' function or a final substring of the host
774 component is a period (U+002E) immediately followed by the argument
775 to the 'domain()' function.</p>
776 <div class="example">
777 <p>For example, this rule:</p>
778 <pre>@document domain("w3.org") {
779 body { font-size: 16px ! important }
780 }</pre>
781 <p>changes the font size of the body element for pages such as
782 <code>http://www.w3.org/Style/CSS/</code> and
783 <code>http://w3.org/Style/CSS/</code> and
784 <code>http://lists.w3.org/Archives/Public/www-style/</code>
785 but it does not affect the page
786 <code>http://www.example.com/Style/CSS/</code>.</p>
787 </div>
788 </dd>
790 <dt><dfn id="url-regexp" title="regexp()|URL matching functions::regular expression">regexp(<string>)</dfn></dt>
792 <dd>
793 <p>The contents of the <string> argument <strong>must</strong>
794 match the JavaScript <code>Pattern</code> production
795 ([[!ECMA-262-5.1]], section 15.10.1). However,
796 failing to do so is not a CSS syntax error and does not trigger any
797 error handling for CSS syntax errors.</p>
799 <p>The ''regexp()'' function evaluates to true whenever the string
800 argument compiled as a JavaScript regular expression with the
801 <code>global</code>, <code>ignoreCase</code> and
802 <code>multiline</code> flags <em>disabled</em>
803 (see [[!ECMA-262-5.1]], sections 15.10.7.2 through 15.10.7.4)
804 compiles successfully and the resulting regular expression matches
805 the entirety of the
806 <a href="#url-of-doc">URL of the document being styled</a>.</p>
808 <p class="note">Note that regular expression must match the entire
809 URL, not just a part of it.</p>
811 <p class="note">Note that this definition intentionally matches the
812 behavior of the <a
813 href="http://dev.w3.org/html5/spec/common-input-element-attributes.html#attr-input-pattern"><code class="html">pattern</code>
814 attribute</a> on the <code class="html">input</code> element
815 in [[HTML5]].</p>
817 <div class="example">
818 <p>For example, this rule:</p>
819 <pre>@document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {
820 body { font-size: 20px ! important }
821 }</pre>
822 <p>changes the font size of the body element for pages such as
823 <code>http://www.w3.org/TR/2011/PR-CSS2-20110412/</code>.</p>
824 <p class="note">Note that the backslashes in the regular
825 expression require CSS escaping as ''\\''.</p>
826 </div>
827 </dd>
829 </dl>
831 <p>Implementations <strong>must</strong> treat any unknown URL matching
832 functions as a syntax error, and thus ignore the '@document' rule.
833 <span class="issue">Should we instead have more complicated error
834 handling rules to make forward-compatibility work differently, or is
835 this rule the best solution for such future expansion anyway?</span></p>
837 <div class="issue">This syntax doesn't offer any ability to do negations,
838 which has been requested in <a
839 href="https://bugzilla.mozilla.org/show_bug.cgi?id=349813">Mozilla bug
840 349813</a>. Use cases that people have wanted negations for
841 include:
842 <ul>
843 <li>User style sheets that want a particular rule in general, but know
844 that that rule does more harm than good on specific sites.</li>
845 <li>Authors who have a rule that they want to apply to most of their
846 pages, but wish to make a few exceptions for.</li>
847 </ul>
848 </div>
850 <p>This extends the lexical scanner in the
851 <a href="http://www.w3.org/TR/CSS21/grammar.html">Grammar of CSS 2.1</a>
852 ([[!CSS21]], Appendix G) by adding:
853 <pre>@{D}{O}{C}{U}{M}{E}{N}{T} {return DOCUMENT_SYM;}</pre>
854 <p>and the grammar by adding</p>
855 <pre><dfn>document_rule</dfn>
856 : DOCUMENT_SYM S+ <i>url_match_fn</i> ( "," S* <i>url_match_fn</i> )* <i>group_rule_body</i>
857 ;
859 <dfn>url_match_fn</dfn>
860 : (URI | FUNCTION S* STRING S* ')' ) S*
861 ;</pre>
862 -->
865 <h2 id="apis">APIs</h2>
867 <h3 id='extentions-to-cssrule-interface'>
868 Extensions to the <code>CSSRule</code> interface</h3>
870 <p>The <code>CSSRule</code> interface is extended as follows:
872 <pre class='idl'>partial interface CSSRule {
873 const unsigned short SUPPORTS_RULE = 12;
874 <!--
875 const unsigned short DOCUMENT_RULE = 13;
876 -->
877 }</pre>
880 <h3 id='the-cssgroupingrule-interface'>
881 The <code>CSSGroupingRule</code> interface</h3>
883 <p>The <dfn><code>CSSGroupingRule</code></dfn> interface represents an at-rule that contains other rules nested inside itself.
885 <pre class='idl'>interface CSSGroupingRule : CSSRule {
886 readonly attribute <a href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSRuleList">CSSRuleList</a> cssRules;
887 unsigned long insertRule (DOMString rule, unsigned long index);
888 void deleteRule (unsigned long index);
889 }</pre>
891 <dl class='idl-attributes'>
892 <dt><code>cssRules</code> of type <code><a href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSRuleList">CSSRuleList</a></code>, readonly
893 <dd>The <code>cssRules</code> attribute must return a <code>CSSRuleList</code>
894 object for the list of CSS rules nested inside the grouping rule.
895 </dl>
897 <dl class='idl-methods'>
898 <dt><code>insertRule(DOMString rule, unsigned long index)</code>, returns
899 <code>unsigned long</code>
900 <dd>
901 The <code>insertRule</code> operation must
902 insert a CSS rule <var>rule</var>
903 into the CSS rule list returned by <code>cssRules</code>,
904 such that the inserted rule will be at position <var>index</var>,
905 and any rules previously at <var>index</var> or higher
906 will increase their index by one.
907 It must throw INDEX_SIZE_ERR
908 if index is greater than <code>cssRules.length</code>.
909 It must throw SYNTAX_ERR
910 if the rule has a syntax error and is unparseable;
911 this does not include syntax errors handled by error handling rules
912 for constructs inside of the rule,
913 but this does include cases where the string given
914 does not parse into a single CSS rule (such as when the string is empty)
915 or where there is anything other than whitespace or comments
916 after that single CSS rule.
917 It must throw HIERARCHY_REQUEST_ERR
918 if the rule cannot be inserted at the location specified,
919 for example, if an ''@import'' rule is inserted inside a group rule.
921 <p>The return value is the <var>index</var> parameter.
923 <dt><code>deleteRule (unsigned long index)</code>, return <code>void</code>
924 <dd>
925 The <code>deleteRule</code> operation must
926 remove a CSS rule from
927 the CSS rule list returned by <code>cssRules</code> at <var>index</var>.
928 It must throw INDEX_SIZE_ERR
929 if index is greater than or equal to <code>cssRules.length</code>.
930 </dl>
933 <h3 id="the-cssconditionrule-interface">
934 The <code>CSSConditionRule</code> interface</h3>
936 <p>The <dfn><code>CSSConditionRule</code></dfn> interface represents all the "conditional" at-rules,
937 which consist of a condition and a statement block.
939 <pre class='idl'>interface CSSConditionRule : CSSGroupingRule {
940 attribute DOMString conditionText;
941 }</pre>
943 <dl class='idl-attributes'>
945 <dt><code>conditionText</code> of type <code>DOMString</code>
946 <dd>
947 <p>The <code>conditionText</code> attribute represents
948 the condition of the rule.
949 Since what this condition does
950 varies between the derived interfaces of <code>CSSConditionRule</code>,
951 those derived interfaces
952 may specify different behavior for this attribute
953 (see, for example, <code>CSSMediaRule</code> below).
954 In the absence of such rule-specific behavior,
955 the following rules apply:</p>
957 <p>The <code>conditionText</code> attribute, on getting, must return
958 the result of serializing the associated condition.
960 <p>On setting the <code>conditionText</code> attribute these steps
961 must be run:
963 <ol>
964 <li>Trim the given value of white space.
965 <li>If the given value matches the grammar of the
966 appropriate condition production for the given rule,
967 replace the associated CSS condition with the given value.
968 <li>Otherwise, do nothing.
969 </ol>
970 </dl>
973 <h3 id="the-cssmediarule-interface">
974 The <code>CSSMediaRule</code> interface</h3>
976 <p>The <dfn><code>CSSMediaRule</code></dfn> interface represents a ''@media'' rule:
978 <pre class='idl'>interface CSSMediaRule : CSSConditionRule {
979 readonly attribute <a href="http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-MediaList">MediaList</a> media;
980 }</pre>
982 <dl class='idl-attributes'>
983 <dt><code>media</code> of type <code><a href="http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-MediaList">MediaList</a></code>, readonly
984 <dd>The <code>media</code> attribute must return a <code>MediaList</code> object
985 for the list of media queries specified with the ''@media'' rule.
987 <dt><code>conditionText</code> of type <code>DOMString</code> (CSSMediaRule-specific definition for attribute on CSSConditionRule)
988 <dd>The <code>conditionText</code> attribute (defined on the <code>CSSConditionRule</code> parent rule),
989 on getting, must return the value of <code>media.mediaText</code> on the rule.
991 <p>Setting the <code>conditionText</code> attribute
992 must set the <code>media.mediaText</code> attribute on the rule.
993 </dl>
996 <h3 id="the-csssupportsrule-interface">
997 The <code>CSSSupportsRule</code> interface</h3>
999 <p>The <dfn><code>CSSSupportsRule</code></dfn> interface represents a ''@supports'' rule.</p>
1001 <pre class='idl'>interface CSSSupportsRule : CSSConditionRule {
1002 }</pre>
1004 <dl class='idl-attributes'>
1005 <dt><code>conditionText</code> of type <code>DOMString</code> (CSSSupportsRule-specific definition for attribute on CSSConditionRule)
1006 <dd>The <code>conditionText</code> attribute (defined on the <code>CSSConditionRule</code> parent rule),
1007 on getting, must return the condition that was specified,
1008 without any logical simplifications,
1009 so that the returned condition will evaluate to the same result
1010 as the specified condition
1011 in any conformant implementation of this specification
1012 (including implementations that implement future extensions
1013 allowed by the <i>general_enclosed</i> exensibility mechanism in this specification).
1014 In other words,
1015 token stream simplifications are allowed
1016 (such as reducing whitespace to a single space
1017 or omitting it in cases where it is known to be optional),
1018 but logical simplifications (such as removal of unneeded parentheses,
1019 or simplification based on evaluating results) are not allowed.
1021 </dl>
1023 <!--
1024 <h3 id="the-cssdocumentrule-interface">
1025 The <code>CSSDocumentRule</code> interface</h3>
1027 <p>The <dfn><code>CSSDocumentRule</code></dfn> interface represents a ''@document'' rule.</p>
1029 <pre class='idl'>interface CSSDocumentRule : CSSConditionRule {
1030 }</pre>
1031 -->
1034 <h3 id='the-css-interface'>
1035 The <code>CSS</code> interface, and the <code title=''>supports()</code> function</h3>
1037 <p>The <dfn id='CSS-interface'><code>CSS</code></dfn> interface holds useful CSS-related functions that do not belong elsewhere.
1039 <pre class='idl'>interface CSS {
1040 static boolean supports(DOMString property, DOMString value);
1041 static boolean supports(DOMString conditionText);
1042 }</pre>
1044 <dl class='idl-methods'>
1045 <dt><code>supports(DOMString property, DOMString value)</code>,
1046 returns <code>boolean</code>
1047 <dt><code>supports(DOMString conditionText)</code>,
1048 returns <code>boolean</code>
1049 <dd>
1050 When the <code title=''>supports()</code> method is invoked with two arguments <var>property</var> and <var>value</var>,
1051 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,
1052 and <var>value</var> would be successfully parsed as a supported value for that property.
1053 (Literal match means that no CSS escape processing is performed,
1054 and leading and trailing whitespace are not stripped,
1055 so any leading whitespace, trailing whitespace,
1056 or CSS escapes equivalent to the name of a property
1057 would cause the method to return <code>false</code>.)
1058 Otherwise, it must return <code>false</code>.
1060 <p>
1061 When invoked with a single <var>conditionText</var> argument,
1062 it must return <code>true</code> if <var>conditionText</var>,
1063 when parsed and evaluated as a <code>supports_condition</code>,
1064 would return true.
1065 Otherwise, it must return <code>false</code>.
1066 </dl>
1069 <h2 class=no-num id="grammar">Grammar</h2>
1071 <p>In order to allow these new @-rules in CSS style sheets, this
1072 specification modifies the <code>stylesheet</code> production in the <a
1073 href="http://www.w3.org/TR/CSS21/grammar.html">Appendix G</a> grammar of
1074 [[!CSS21]] by replacing the <code>media</code> production defined in
1075 [[!CSS21]] with the <code>media</code> production defined in this one,
1076 and additionally inserting <code>| supports_rule</code>
1077 alongside <code>ruleset | media | page</code>.</p>
1080 <h2 id="conformance">Conformance</h2>
1082 <h3 id="base-modules">Base Modules</h3>
1084 <p>This specification defines conformance in terms of base modules,
1085 which are modules that this specification builds on top of. The base
1086 modules of this module are:</p>
1088 <ul>
1089 <li>[[!CSS21]]</li>
1090 </ul>
1092 <p>All of the conformance requirements of all base modules are
1093 incorporated as conformance requirements of this module, except where
1094 overridden by this module.</p>
1096 <p>Additionally, all conformance requirements related to validity of
1097 syntax in this module and all of its base modules are to be interpreted
1098 as though all syntax in all of those modules is valid.</p>
1100 <div class="example"><p>For example, this means that grammar presented
1101 in modules other than [[!CSS21]] must obey the requirements that
1102 [[!CSS21]] defines for the parsing of properties, and that requirements
1103 for handling invalid syntax in [[!CSS21]] do not treat syntax added by
1104 other modules as invalid.</p></div>
1106 <p>Additionally, the set of valid syntax can be increased by the
1107 conformance of a style sheet or processor to additional modules; use of
1108 such syntax does not make a style sheet nonconformant and failure to
1109 treat such syntax as invalid does not make a processor
1110 nonconformant.</p>
1112 <h3 id="conformance-classes">Conformance Classes</h3>
1114 <p>Conformance to the CSS Conditional Rules Module is defined for three
1115 conformance classes:
1116 <dl>
1117 <dt><dfn title="conformance::style sheet" id="conform-style-sheet">style sheet</dfn>
1118 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
1119 style sheet</a>.</dd>
1120 <dt><dfn title="conformance::processor" id="conform-processor">processor</dfn></dt>
1121 <dd>A tool that reads CSS style sheets: it may be a renderer or
1122 <a
1123 href="http://www.w3.org/TR/CSS21/conform.html#user-agent">user-agent</a>
1124 that interprets the semantics of a style sheet and renders
1125 documents that use style sheets, or it may be a validator that
1126 checks style sheets.</dd>
1127 <dt><dfn title="conformance::authoring tool" id="conform-authoring-tool">authoring tool</dfn></dt>
1128 <dd>A tool that writes a style sheet.</dd>
1129 </dl>
1131 <p>A style sheet is conformant to the CSS Conditional Rules Module
1132 if it meets all of the conformance requirements in the module that are
1133 described as requirements of style sheets.</p>
1135 <p>A processor is conformant to the CSS Conditional Rules Module if it
1136 meets all applicable conformance requirements in the module that are
1137 described as requirements of processors. In general, all requirements
1138 are applicable to renderers. Requirements concerning a part of CSS
1139 not performed by a processor are not applicable, e.g., requirements
1140 related to rendering are not applicable to a validator. The inability
1141 of a processor to correctly render a document due to limitations of
1142 the device does not make it non-conformant. (For example, a renderer
1143 is not required to render color on a monochrome monitor.)</p>
1145 <p>An authoring tool is conformant to the CSS Conditional Rules Module
1146 if it writes style sheets that conform to the module and (if it reads
1147 CSS) it is a conformant processor.</p>
1149 <h3 id="partial">
1150 Partial Implementations</h3>
1152 <p>So that authors can exploit the forward-compatible parsing rules to
1153 assign fallback values, CSS renderers <strong>must</strong>
1154 treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore
1155 as appropriate</a>) any at-rules, properties, property values, keywords,
1156 and other syntactic constructs for which they have no usable level of
1157 support. In particular, user agents <strong>must not</strong> selectively
1158 ignore unsupported component values and honor supported values in a single
1159 multi-value property declaration: if any value is considered invalid
1160 (as unsupported values must be), CSS requires that the entire declaration
1161 be ignored.</p>
1163 <h3 id="experimental">Experimental Implementations</h3>
1165 <p>To avoid clashes with future CSS features, the CSS specifications
1166 reserve a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">prefixed
1167 syntax</a> for proprietary property and value extensions to CSS. The CSS
1168 Working Group recommends that experimental implementations of features in
1169 CSS Working Drafts also use vendor-prefixed property or value names. This
1170 avoids any incompatibilities with future changes in the draft. Once a
1171 specification reaches the Candidate Recommendation stage, implementors
1172 should implement the non-prefixed syntax for any feature they consider to
1173 be correctly implemented according to spec.</p>
1175 <h3 id="cr-exit-criteria">CR Exit Criteria</h3>
1177 <p>For this specification to be advanced to Proposed Recommendation,
1178 there must be at least two independent, interoperable implementations
1179 of each feature. Each feature may be implemented by a different set of
1180 products, there is no requirement that all features be implemented by
1181 a single product. For the purposes of this criterion, we define the
1182 following terms:
1184 <dl>
1185 <dt>independent <dd>each implementation must be developed by a
1186 different party and cannot share, reuse, or derive from code
1187 used by another qualifying implementation. Sections of code that
1188 have no bearing on the implementation of this specification are
1189 exempt from this requirement.
1191 <dt>interoperable <dd>passing the respective test case(s) in the
1192 official CSS test suite, or, if the implementation is not a Web
1193 browser, an equivalent test. Every relevant test in the test
1194 suite should have an equivalent test created if such a user
1195 agent (UA) is to be used to claim interoperability. In addition
1196 if such a UA is to be used to claim interoperability, then there
1197 must one or more additional UAs which can also pass those
1198 equivalent tests in the same way for the purpose of
1199 interoperability. The equivalent tests must be made publicly
1200 available for the purposes of peer review.
1202 <dt>implementation <dd>a user agent which:
1204 <ol class=inline>
1205 <li>implements the specification.
1207 <li>is available to the general public. The implementation may
1208 be a shipping product or other publicly available version
1209 (i.e., beta version, preview release, or “nightly build”).
1210 Non-shipping product releases must have implemented the
1211 feature(s) for a period of at least one month in order to
1212 demonstrate stability.
1214 <li>is not experimental (i.e., a version specifically designed
1215 to pass the test suite and is not intended for normal usage
1216 going forward).
1217 </ol>
1218 </dl>
1220 <p>The specification will remain Candidate Recommendation for at least
1221 six months.
1223 <h2 id="changes">
1224 Changes</h2>
1226 <p>The following (non-editorial) changes were made to this specification since the
1227 <a href="http://www.w3.org/TR/2012/WD-css3-conditional-20121213/">13 December 2012 Working Draft</a>:
1229 <ul>
1230 <li>Require whitespace around ''and'' and ''or'' and after ''not''.
1231 <li>Add note explaining that user preferences that effectively disable a property (e.g., high-contrast mode disabling colors) do not effect the definition of support.
1232 <li>Describe requirements for conditionText getter on CSSSupportsRule.
1233 <li>Clarify the definition of "literal match" in CSS.supports().
1234 <li>Specify behavior of CSSGroupingRule.insertRule when given an empty string or more than one syntactically valid rule.
1235 </ul>
1237 <h2 class=no-num id="acknowledgments">Acknowledgments</h2>
1239 <p>
1240 Thanks to the ideas and feedback from
1241 Tab Atkins,
1242 Arthur Barstow,
1243 Ben Callahan,
1244 <span lang="tr">Tantek Çelik</span>,
1245 Alex Danilo,
1246 Elika Etemad,
1247 Pascal Germroth,
1248 <span lang="de">Björn Höhrmann</span>,
1249 Paul Irish,
1250 <span lang="nl">Anne van Kesteren</span>,
1251 Vitor Menezes,
1252 Alex Mogilevsky,
1253 Chris Moschini,
1254 James Nurthen,
1255 Simon Pieters,
1256 <span lang="fr">Florian Rivoal</span>,
1257 <span lang="fr">Simon Sapin</span>,
1258 Nicholas Shanks,
1259 Ben Ward,
1260 Zack Weinberg,
1261 Estelle Weyl,
1262 Boris Zbarsky,
1263 and all the rest of the <a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.
1265 </p>
1267 <h2 class=no-num id="references">References</h2>
1270 <h3 class="no-num" id="normative-references">Normative references</h3>
1271 <!--normative-->
1273 <h3 class="no-num" id="other-references">Other references</h3>
1274 <!--informative-->
1276 <h2 class="no-num" id="index">Index</h2>
1277 <!--index-->
1279 </body>
1280 </html>
1281 <!-- Keep this comment at the end of the file
1282 Local variables:
1283 mode: sgml
1284 sgml-declaration:"~/SGML/HTML4.decl"
1285 sgml-default-doctype-name:"html"
1286 sgml-minimize-attributes:t
1287 sgml-nofill-elements:("pre" "style" "br")
1288 sgml-live-element-indicator:t
1289 sgml-omittag:nil
1290 sgml-shorttag:nil
1291 sgml-namecase-general:t
1292 sgml-general-insert-case:lower
1293 sgml-always-quote-attributes:t
1294 sgml-indent-step:nil
1295 sgml-indent-data:t
1296 sgml-parent-document:nil
1297 sgml-exposed-tags:nil
1298 sgml-local-catalogs:nil
1299 sgml-local-ecat-files:nil
1300 End:
1301 -->