css3-conditional/Overview.src.html

Thu, 21 Feb 2013 14:36:22 -0800

author
Tantek Çelik <tantek@cs.stanford.edu>
date
Thu, 21 Feb 2013 14:36:22 -0800
changeset 7538
9d25222da9cb
parent 7412
3b40faa91133
child 7733
ef41ff04d9a8
permissions
-rw-r--r--

[css3-conditional] add h-card h-entry

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

mercurial