css-conditional/Overview.src.html

Thu, 04 Apr 2013 16:16:28 +0200

author
Bert Bos <bert@w3.org>
date
Thu, 04 Apr 2013 16:16:28 +0200
changeset 7907
4cf8a925226d
parent 7863
b37f9017599f
child 7933
99e6228da0b8
permissions
-rw-r--r--

[css3-conditional] Sync with CR publication.

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

mercurial