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