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