CARVIEW |
CSS Conditional Rules Module Level 3
W3C Candidate Recommendation 4 April 2013
- This version:
- https://www.w3.org/TR/2013/CR-css3-conditional-20130404/
- Latest version:
- https://www.w3.org/TR/css3-conditional/
- Editor's draft:
- https://dev.w3.org/csswg/css3-conditional/ (change log, older change log)
- Previous version:
- https://www.w3.org/TR/2012/WD-css3-conditional-20121213/
- Editors:
- L. David Baron, Mozilla
- Issues list:
- Maintained in document (only editor's draft is current)
- Feedback:
- www-style@w3.org with subject line “[css3-conditional] … message topic …” (archives)
- Test suite:
- submitted tests, nightly test suite
Copyright © 2013 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
Abstract
CSS is a language for describing the rendering of structured documents
(such as HTML and XML) on screen, on paper, in speech, etc. This module contains the features of CSS for conditional
processing of parts of style sheets, conditioned on capabilities of the
processor or the document the style sheet is being applied to. It includes
and extends the functionality of CSS level 2 [CSS21], which builds on CSS level 1
[CSS1]. The main
extensions compared to level 2 are allowing nesting of certain at-rules
inside ‘@media
’, and the addition of the
‘@supports
’ rule for conditional processing.
Status of this document
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.
This document was produced by the CSS Working Group as a Candidate Recommendation.
A Candidate Recommendation is a document that has been widely reviewed and is ready for implementation. W3C encourages everybody to implement this specification and return comments to the (archived) public mailing list www-style@w3.org (see instructions). When sending e-mail, please put the text “css3-conditional” in the subject, preferably like this: “[css3-conditional] …summary of comment…”
Publication as a Candidate Recommendation does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
See the section “CR Exit Criteria” for details on advancing this specification to W3C Recommendation. The specification will remain Candidate Recommendation at least until 2 October 2013. A test suite and implementation report are under development.
See the section “Changes” for changes since the last Working Draft.
The following features are at risk:
- The inclusion of ‘
@font-face
’ rules and ‘@keyframes
’ rules as allowed within all of the @-rules in this specification is at risk, though only because of the relative rates of advancement of specifications. If this specification is able to advance faster than one or both of the specifications defining those rules, then the inclusion of those rules will move from this specification to the specification defining those rules. - The addition of support for @-rules inside of conditional grouping rules is at risk; if interoperable implementations are not found, it may be removed to advance the other features in this specification to Proposed Recommendation.
- The ‘
@supports
’ rule is at risk; if interoperable implementations are not found, it may be removed to advance the other features in this specification to Proposed Recommendation.
Table of contents
- 1. Introduction
- 2. Processing of conditional group rules
- 3. Contents of conditional group rules
- 4. Placement of conditional group rules
- 5. Media-specific style
sheets: the ‘
@media
’ rule - 6. Feature queries:
the ‘
@supports
’ rule - 7. APIs
- Grammar
- 8. Conformance
- 9. Changes
- Acknowledgments
- References
- Index
1. Introduction
1.1. Background
This section is not normative.
[CSS21] defines
one type of conditional group rule, the ‘@media
’ rule, and allows only rulesets (not other
@-rules) inside of it. The ‘@media
’ rule
provides the ability to have media-specific style sheets, which is also
provided by style sheet linking features such as ‘@import
’ and <link>
. The
restrictions on the contents of ‘@media
’ rules
made them less useful; they have forced authors using CSS features
involving @-rules in media-specific style sheets to use separate style
sheets for each medium.
This specification extends the rules for the contents of conditional group rules to allow other @-rules, which enables authors to combine CSS features involving @-rules with media specific style sheets within a single style sheet.
This specification also defines an additional type of conditional group
rule, ‘@supports
’, to address author and user
requirements.
The ‘@supports
’ rule allows CSS to be
conditioned on implementation support for CSS properties and values. This
rule makes it much easier for authors to use new CSS features and provide
good fallback for implementations that do not support those features. This
is particularly important for CSS features that provide new layout
mechanisms, and for other cases where a set of related styles needs to be
conditioned on property support.
1.2. Module Interactions
This module replaces and extends the ‘@media
’
rule feature defined in [CSS21] section 7.2.1 and
incorporates the modifications previously made non-normatively by [MEDIAQ] section
1.
Its current definition depends on @-rules defined in [CSS3-FONTS] and [CSS3-ANIMATIONS], but that dependency is only on the assumption that those modules will advance ahead of this one. If this module advances faster, then the dependency will be reversed.
1.3. Document Conventions
Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words “for
example” or are set apart from the normative text with class="example"
, like this:
This is an example of an informative example.
Informative notes begin with the word “Note” and are set apart from
the normative text with class="note"
, like this:
Note, this is an informative note.
2. Processing of conditional group rules
This specification defines some CSS @-rules, called conditional group rules, that associate a condition with a group of other CSS rules. These different rules allow testing different types of conditions, but share common behavior for how their contents are used when the condition is true and when the condition is false.
For example, this rule:
@media print { /* hide navigation controls when printing */ #navigation { display: none } }
causes a particular CSS rule (making elements with ID "navigation" be display:none) apply only when the style sheet is used for a print medium.
Each conditional group rule has a condition, which at any time evaluates to true or false. When the condition is true, CSS processors must apply the rules inside the group rule as though they were at the group rule's location; when the condition is false, CSS processors must not apply any of rules inside the group rule. The current state of the condition does not affect the CSS object model, in which the contents of the group rule always remain within the group rule.
This means that when multiple conditional group rules are nested, a rule inside of both of them applies only when all of the rules' conditions are true.
@media print { // rule (1) /* hide navigation controls when printing */ #navigation { display: none } @media (max-width: 12cm) { // rule (2) /* keep notes in flow when printing to narrow pages */ .note { float: none } } }the condition of the rule marked (1) is true for print media, and the condition of the rule marked (2) is true when the width of the display area (which for print media is the page box) is less than or equal to 12cm. Thus the rule ‘
#navigation { display: none
}
’ applies whenever this style sheet is applied to print media,
and the rule ‘.note { float: none }
’ is applied
only when the style sheet is applied to print media and the width
of the page box is less than or equal to 12 centimeters.When the condition for a conditional group rule changes, CSS processors must reflect that the rules now apply or no longer apply, except for properties whose definitions define effects of computed values that persist past the lifetime of that value (such as for some properties in [CSS3-TRANSITIONS] and [CSS3-ANIMATIONS]).
3. Contents of conditional group rules
The syntax of each conditional group rule consists of some syntax specific to the type of rule followed by a group rule body, which is a block (pair of braces) containing a sequence of rules.
A group rule body is allowed to contain rulesets and any @-rules that
are allowed at the top level of a style sheet before and after a ruleset.
This means that @-rules that must occur at the beginning of the style
sheet (such as ‘@charset
’, ‘@import
’, and ‘@namespace
’
rules) are not allowed inside of conditional group rules. Conditional
group rules can be nested.
In terms of the grammar, this specification defines the following productions for use in the grammar of conditional group rules:
nested_statement : ruleset | media | page | font_face_rule | keyframes_rule | supports_rule ; group_rule_body : '{' S* nested_statement* '}' S* ;
in which all the productions are defined in that grammar with the
exception of font_face_rule
defined in [CSS3-FONTS],
keyframes_rule
defined in [CSS3-ANIMATIONS], and media
and supports_rule
defined in this
specification.
In general, future CSS specifications that add new @-rules that are not
forbidden to occur after some other types of rules should modify this nested_statement
production to
keep the grammar accurate.
Style sheets must not use rules other than the allowed ones inside conditional group rules.
CSS processors must ignore rules that are not allowed within a group rule, and must handle invalid rules inside of group rules as described in section 4.2 (Rules for handling parsing errors), section 4.1.5 (At-rules), and section 4.1.7 (Rule sets, declaration blocks, and selectors) of [CSS21].
4. Placement of conditional group rules
Conditional group rules are allowed at the top-level of a style sheet, and inside other conditional group rules. CSS processors must process such rules as described above.
Any rules that are not allowed after a ruleset (e.g., ‘@charset
’, ‘@import
’, or
‘@namespace
’ rules) are also not allowed after
a conditional group rule. Therefore, style sheets must
not place such rules after a conditional group rules, and CSS
processors must ignore such rules.
5. Media-specific style sheets:
the ‘@media
’ rule
The ‘@media
’ rule
is a conditional group rule whose condition is a media query. It consists
of the at-keyword ‘@media
’ followed by a
(possibly empty) media query list (as defined in [MEDIAQ]), followed by a group rule
body. The condition of the rule is the result of the media query.
This ‘@media
’ rule:
@media screen and (min-width: 35em), print and (min-width: 40em) { #section_navigation { float: left; width: 10em; } }
has the condition ‘screen and (min-width: 35em),
print and (min-width: 40em)
’, which is true for screen displays
whose viewport is at least 35 times the initial font size and for print
displays whose viewport is at least 40 times the initial font size. When
either of these is true, the condition of the rule is true, and the rule
‘#section_navigation { float: left; width: 10em;
}
’ is applied.
In terms of the grammar, this specification extends the media
production in the Grammar of CSS 2.1 ([CSS21], Appendix G)
into:
media : MEDIA_SYM S* media_query_list group_rule_body ;
where the group_rule_body
production is defined in this specification, the
media_query_list
production is defined in [MEDIAQ], and the others are defined
in the Grammar of CSS
2.1 ([CSS21],
Appendix G).
6. Feature queries: the
‘@supports
’ rule
The ‘@supports
’
rule is a conditional group rule whose condition tests whether the
user agent supports CSS property:value pairs. Authors can use it to write
style sheets that use new features when available but degrade gracefully
when those features are not supported. CSS has existing mechanisms for
graceful degradation, such as ignoring unsupported properties or values,
but these are not always sufficient when large groups of styles need to be
tied to the support for certain features, as is the case for use of new
layout system features.
The syntax of the condition in the ‘@supports
’ rule is slightly more complicated than for
the other conditional group rules (though has some similarities to media
queries) since:
- negation is needed so that the new-feature styles and the fallback styles can be separated (within the forward-compatible grammar's rules for the syntax of @-rules), and not required to override each other
- conjunction (and) is needed so that multiple required features can be tested
- disjunction (or) is needed when there are multiple alternative features for a set of styles, particularly when some of those alternatives are vendor-prefixed properties or values
Therefore, the syntax of the ‘@supports
’ rule
allows testing for property:value pairs, and arbitrary conjunctions (and),
disjunctions (or), and negations (not) of them.
This extends the lexical scanner in the Grammar of CSS 2.1 ([CSS21], Appendix G) by adding:
@{S}{U}{P}{P}{O}{R}{T}{S} {return SUPPORTS_SYM;} {O}{R} {return OR;}
This then extends the grammar in the Grammar of CSS 2.1,
using the lexical scanner there, with the additions of AND
and
NOT
tokens defined in the Media Queries specification [MEDIAQ] and the OR
and SUPPORTS_SYM
tokens defined above,
and with declaration
,
any
,
and unused
productions and the FUNCTION
token taken from the core syntax of CSS defined in section 4.1.1
(Tokenization) of [CSS21], by adding:
supports_rule : SUPPORTS_SYM S* supports_condition S* group_rule_body ; supports_condition : supports_negation | supports_conjunction | supports_disjunction | supports_condition_in_parens ; supports_condition_in_parens : ( '(' S* supports_condition S* ')' ) | supports_declaration_condition | general_enclosed ; supports_negation : NOT S+ supports_condition_in_parens ; supports_conjunction : supports_condition_in_parens ( S+ AND S+ supports_condition_in_parens )+ ; supports_disjunction : supports_condition_in_parens ( S+ OR S+ supports_condition_in_parens )+ ; supports_declaration_condition : '(' S* declaration ')' ; general_enclosed : ( FUNCTION | '(' ) ( any | unused )* ')' ;
Implementations must parse ‘@supports
’ rules based on the above grammar, and when
interpreting the above grammar, must match the production
before an |
operator in preference to the one after it.
The above grammar is purposely very loose for forwards-compatibility
reasons, since the general_enclosed
production
allows for substantial future extensibility. Any ‘@supports
’ rule that does not parse according to the
grammar above (that is, a rule that does not match this loose grammar
which includes the general_enclosed
production) is
invalid. Style sheets must not use such a rule and
processors must ignore such a rule (including all of its
contents).
Each of these grammar terms is associated with a boolean result, as follows:
- supports_condition
- The result is the result of the single child term.
- supports_condition_in_parens
- The result is the result of the single
supports_condition
orsupports_declaration_condition
child term. - supports_negation
- The result is the negation of the result of the
supports_condition_in_parens
child term. - supports_conjunction
- The result is true if the result of all of the
supports_condition_in_parens
child terms is true; otherwise it is false. - supports_disjunction
- The result is true if the result of any of the
supports_condition_in_parens
child terms is true; otherwise it is false. - supports_declaration_condition
- The result is whether the CSS processor supports the declaration within the parentheses.
- general_enclosed
- The result is always false. Additionally, style sheets must
not write ‘
@supports
’ rules that match this grammar production. (In other words, this production exists only for future extensibility, and is not part of the description of a valid style sheet in this level of the specification.) Note that future levels may define functions or other parenthesized expressions that can evaluate to true.
The condition of the ‘@supports
’ rule is the
result of the supports_condition
term that
is a child of the supports_rule
term.
For example, the following rule
@supports ( display: flexbox ) { body, #navigation, #content { display: flexbox; } #navigation { background: blue; color: white; } #article { background: white; color: black; } }
applies the rules inside the ‘@supports
’
rule only when ‘display: flexbox
’ is
supported.
The following example shows an additional ‘@supports
’ rule that can be used to provide an
alternative for when ‘display: flexbox
’ is not
supported:
@supports not ( display: flexbox ) { body { width: 100%; height: 100%; background: white; color: black; } #navigation { width: 25%; } #article { width: 75%; } }
Note that the ‘width
’ declarations may
be harmful to the flexbox-based layout, so it is important that they be
present only in the non-flexbox styles.
The following example checks for support for the ‘box-shadow
’ property, including checking for
support for vendor-prefixed versions of it. When the support is present,
it specifies both ‘box-shadow
’ (with the
prefixed versions) and ‘color
’ in a way
what would cause the text to become invisible were ‘box-shadow
’ not supported.
@supports ( box-shadow: 2px 2px 2px black ) or ( -moz-box-shadow: 2px 2px 2px black ) or ( -webkit-box-shadow: 2px 2px 2px black ) or ( -o-box-shadow: 2px 2px 2px black ) { .outline { color: white; -moz-box-shadow: 2px 2px 2px black; -webkit-box-shadow: 2px 2px 2px black; -o-box-shadow: 2px 2px 2px black; box-shadow: 2px 2px 2px black; /* unprefixed last */ } }
To avoid confusion between ‘and
’ and ‘or
’, the syntax requires that both
‘and
’ and ‘or
’ be specified explicitly (rather than, say,
using commas or spaces for one of them). Likewise, to avoid confusion
caused by precedence rules, the syntax does not allow ‘and
’, ‘or
’, and ‘not
’ operators
to be mixed without a layer of parentheses.
For example, the following rule is not valid:
@supports (transition-property: color) or (animation-name: foo) and (transform: rotate(10deg)) { // ... }
Instead, authors must write one of the following:
@supports ((transition-property: color) or (animation-name: foo)) and (transform: rotate(10deg)) { // ... }
@supports (transition-property: color) or ((animation-name: foo) and (transform: rotate(10deg))) { // ... }
Furthermore, whitespace is required after a ‘not
’ and on both sides of an ‘and
’ or ‘or
’.
The declaration being tested must always occur within parentheses, when it is the only thing in the expression.
For example, the following rule is not valid:
@supports display: flexbox { // ... }
Instead, authors must write:
@supports (display: flexbox) { // ... }
The syntax allows extra parentheses when they are not needed. This flexibility is sometimes useful for authors (for example, when commenting out parts of an expression) and may also be useful for authoring tools.
For example, authors may write:
@supports ((display: flexbox)) { // ... }
A trailing ‘!important
’ on a declaration
being tested is allowed, though it won't change the validity of the
declaration.
For example, the following rule is valid:
@supports (display: flexbox !important) { // ... }
6.1. Definition of support
For forward-compatibility, section 4.1.8 (Declarations and properties) of [CSS21] defines rules for handling invalid properties and values. CSS processors that do not implement or partially implement a specification must treat any part of a value that they do not implement, or do not have a usable level of support for, as invalid according to this rule for handling invalid properties and values, and therefore must discard the declaration as a parse error.
A CSS processor is considered to support a declaration (consisting of a property and value) if it accepts that declaration (rather than discarding it as a parse error). If a processor does not implement, with a usable level of support, the value given, then it must not accept the declaration or claim support for it.
Note that properties or values whose support is effectively
disabled by user preferences are still considered as supported by this
definition. For example, if a user has enabled a high-contrast mode that
causes colors to be overridden, the CSS processor is still considered to
support the ‘color
’ property even though
declarations of the ‘color
’ property may
have no effect. On the other hand, a developer-facing preference whose
purpose is to enable or disable support for an experimental CSS feature
does affect this definition of support.
These rules (and the equivalence between them) allow authors to use
fallback (either in the [CSS1] sense of declarations that are
overridden by later declarations or with the new capabilities provided by
the ‘@supports
’ rule in this specification)
that works correctly for the features implemented. This applies especially
to compound values; implementations must implement all parts of the value
in order to consider the declaration supported, either inside a ruleset or
in the declaration condition of an ‘@supports
’
rule.
7. APIs
7.1.
Extensions to the CSSRule
interface
The CSSRule
interface is extended as follows:
partial interface CSSRule { const unsigned short SUPPORTS_RULE = 12; }
7.2. The CSSGroupingRule
interface
The CSSGroupingRule
interface
represents an at-rule that contains other rules nested inside itself.
interface CSSGroupingRule : CSSRule { readonly attribute CSSRuleList cssRules; unsigned long insertRule (DOMString rule, unsigned long index); void deleteRule (unsigned long index); }
cssRules
of typeCSSRuleList
, readonly- The
cssRules
attribute must return aCSSRuleList
object for the list of CSS rules nested inside the grouping rule.
insertRule(DOMString rule, unsigned long index)
, returnsunsigned long
- The
insertRule
operation must insert a CSS rule rule into the CSS rule list returned bycssRules
, such that the inserted rule will be at position index, and any rules previously at index or higher will increase their index by one. It must throw INDEX_SIZE_ERR if index is greater thancssRules.length
. It must throw SYNTAX_ERR if the rule has a syntax error and is unparseable; this does not include syntax errors handled by error handling rules for constructs inside of the rule, but this does include cases where the string given does not parse into a single CSS rule (such as when the string is empty) or where there is anything other than whitespace or comments after that single CSS rule. It must throw HIERARCHY_REQUEST_ERR if the rule cannot be inserted at the location specified, for example, if an ‘@import
’ rule is inserted inside a group rule.The return value is the index parameter.
deleteRule (unsigned long index)
, returnvoid
- The
deleteRule
operation must remove a CSS rule from the CSS rule list returned bycssRules
at index. It must throw INDEX_SIZE_ERR if index is greater than or equal tocssRules.length
.
7.3. The CSSConditionRule
interface
The CSSConditionRule
interface represents all the "conditional" at-rules, which consist of a
condition and a statement block.
interface CSSConditionRule : CSSGroupingRule { attribute DOMString conditionText; }
conditionText
of typeDOMString
-
The
conditionText
attribute represents the condition of the rule. Since what this condition does varies between the derived interfaces ofCSSConditionRule
, those derived interfaces may specify different behavior for this attribute (see, for example,CSSMediaRule
below). In the absence of such rule-specific behavior, the following rules apply:The
conditionText
attribute, on getting, must return the result of serializing the associated condition.On setting the
conditionText
attribute these steps must be run:- Trim the given value of white space.
- If the given value matches the grammar of the appropriate condition production for the given rule, replace the associated CSS condition with the given value.
- Otherwise, do nothing.
7.4. The CSSMediaRule
interface
The CSSMediaRule
interface
represents a ‘@media
’ rule:
interface CSSMediaRule : CSSConditionRule { readonly attribute MediaList media; }
media
of typeMediaList
, readonly- The
media
attribute must return aMediaList
object for the list of media queries specified with the ‘@media
’ rule. conditionText
of typeDOMString
(CSSMediaRule-specific definition for attribute on CSSConditionRule)- The
conditionText
attribute (defined on theCSSConditionRule
parent rule), on getting, must return the value ofmedia.mediaText
on the rule.Setting the
conditionText
attribute must set themedia.mediaText
attribute on the rule.
7.5. The CSSSupportsRule
interface
The CSSSupportsRule
interface
represents a ‘@supports
’ rule.
interface CSSSupportsRule : CSSConditionRule { }
conditionText
of typeDOMString
(CSSSupportsRule-specific definition for attribute on CSSConditionRule)- The
conditionText
attribute (defined on theCSSConditionRule
parent rule), on getting, must return the condition that was specified, without any logical simplifications, so that the returned condition will evaluate to the same result as the specified condition in any conformant implementation of this specification (including implementations that implement future extensions allowed by the general_enclosed exensibility mechanism in this specification). In other words, token stream simplifications are allowed (such as reducing whitespace to a single space or omitting it in cases where it is known to be optional), but logical simplifications (such as removal of unneeded parentheses, or simplification based on evaluating results) are not allowed.
7.6. The CSS
interface, and the supports()
function
The CSS
interface holds useful
CSS-related functions that do not belong elsewhere.
interface CSS { static boolean supports(DOMString property, DOMString value); static boolean supports(DOMString conditionText); }
supports(DOMString property, DOMString value)
, returnsboolean
supports(DOMString conditionText)
, returnsboolean
- When the
supports()
method is invoked with two arguments property and value, it must returntrue
if property is a literal match for the name of a CSS property that the UA supports, and value would be successfully parsed as a supported value for that property. (Literal match means that no CSS escape processing is performed, and leading and trailing whitespace are not stripped, so any leading whitespace, trailing whitespace, or CSS escapes equivalent to the name of a property would cause the method to returnfalse
.) Otherwise, it must returnfalse
.When invoked with a single conditionText argument, it must return
true
if conditionText, when parsed and evaluated as asupports_condition
, would return true. Otherwise, it must returnfalse
.
Grammar
In order to allow these new @-rules in CSS style sheets, this
specification modifies the stylesheet
production in the Appendix G grammar of
[CSS21] by replacing
the media
production defined in [CSS21] with the media
production defined in this one, and
additionally inserting | supports_rule
alongside
ruleset | media | page
.
8. Conformance
8.1. Base Modules
This specification defines conformance in terms of base modules, which are modules that this specification builds on top of. The base modules of this module are:
All of the conformance requirements of all base modules are incorporated as conformance requirements of this module, except where overridden by this module.
Additionally, all conformance requirements related to validity of syntax in this module and all of its base modules are to be interpreted as though all syntax in all of those modules is valid.
For example, this means that grammar presented in modules other than [CSS21] must obey the requirements that [CSS21] defines for the parsing of properties, and that requirements for handling invalid syntax in [CSS21] do not treat syntax added by other modules as invalid.
Additionally, the set of valid syntax can be increased by the conformance of a style sheet or processor to additional modules; use of such syntax does not make a style sheet nonconformant and failure to treat such syntax as invalid does not make a processor nonconformant.
8.2. Conformance Classes
Conformance to the CSS Conditional Rules Module is defined for three conformance classes:
- style sheet
- A CSS style sheet.
- processor
- A tool that reads CSS style sheets: it may be a renderer or user-agent that interprets the semantics of a style sheet and renders documents that use style sheets, or it may be a validator that checks style sheets.
- authoring tool
- A tool that writes a style sheet.
A style sheet is conformant to the CSS Conditional Rules Module if it meets all of the conformance requirements in the module that are described as requirements of style sheets.
A processor is conformant to the CSS Conditional Rules Module if it meets all applicable conformance requirements in the module that are described as requirements of processors. In general, all requirements are applicable to renderers. Requirements concerning a part of CSS not performed by a processor are not applicable, e.g., requirements related to rendering are not applicable to a validator. The inability of a processor to correctly render a document due to limitations of the device does not make it non-conformant. (For example, a renderer is not required to render color on a monochrome monitor.)
An authoring tool is conformant to the CSS Conditional Rules Module if it writes style sheets that conform to the module and (if it reads CSS) it is a conformant processor.
8.3. Partial Implementations
So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.
8.4. Experimental Implementations
To avoid clashes with future CSS features, the CSS specifications reserve a prefixed syntax for proprietary property and value extensions to CSS. The CSS Working Group recommends that experimental implementations of features in CSS Working Drafts also use vendor-prefixed property or value names. This avoids any incompatibilities with future changes in the draft. Once a specification reaches the Candidate Recommendation stage, implementors should implement the non-prefixed syntax for any feature they consider to be correctly implemented according to spec.
8.5. CR Exit Criteria
For this specification to be advanced to Proposed Recommendation, there must be at least two independent, interoperable implementations of each feature. Each feature may be implemented by a different set of products, there is no requirement that all features be implemented by a single product. For the purposes of this criterion, we define the following terms:
- independent
- each implementation must be developed by a different party and cannot share, reuse, or derive from code used by another qualifying implementation. Sections of code that have no bearing on the implementation of this specification are exempt from this requirement.
- interoperable
- passing the respective test case(s) in the official CSS test suite, or, if the implementation is not a Web browser, an equivalent test. Every relevant test in the test suite should have an equivalent test created if such a user agent (UA) is to be used to claim interoperability. In addition if such a UA is to be used to claim interoperability, then there must one or more additional UAs which can also pass those equivalent tests in the same way for the purpose of interoperability. The equivalent tests must be made publicly available for the purposes of peer review.
- implementation
- a user agent which:
- implements the specification.
- is available to the general public. The implementation may be a shipping product or other publicly available version (i.e., beta version, preview release, or “nightly build”). Non-shipping product releases must have implemented the feature(s) for a period of at least one month in order to demonstrate stability.
- is not experimental (i.e., a version specifically designed to pass the test suite and is not intended for normal usage going forward).
The specification will remain Candidate Recommendation for at least six months.
9. Changes
The following (non-editorial) changes were made to this specification since the 13 December 2012 Working Draft:
- Require whitespace around ‘
and
’ and ‘or
’ and after ‘not
’. - 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.
- Describe requirements for conditionText getter on CSSSupportsRule.
- Clarify the definition of "literal match" in CSS.supports().
- Specify behavior of CSSGroupingRule.insertRule when given an empty string or more than one syntactically valid rule.
Acknowledgments
Thanks to the ideas and feedback from Tab Atkins, Arthur Barstow, Ben Callahan, Tantek Çelik, Alex Danilo, Elika Etemad, Pascal Germroth, Björn Höhrmann, Paul Irish, Anne van Kesteren, Vitor Menezes, Alex Mogilevsky, Chris Moschini, James Nurthen, Simon Pieters, Florian Rivoal, Simon Sapin, Nicholas Shanks, Ben Ward, Zack Weinberg, Estelle Weyl, Boris Zbarsky, and all the rest of the www-style community.
References
Normative references
-
- [CSS21]
- Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. 7 June 2011. W3C Recommendation. URL: https://www.w3.org/TR/2011/REC-CSS2-20110607
- [CSS3-ANIMATIONS]
- Dean Jackson; et al. CSS Animations. 19 February 2013. W3C Working Draft. (Work in progress.) URL: https://www.w3.org/TR/2013/WD-css3-animations-20130219/
- [CSS3-FONTS]
- John Daggett. CSS Fonts Module Level 3. 12 February 2013. W3C Working Draft. (Work in progress.) URL: https://www.w3.org/TR/2013/WD-css3-fonts-20130212/
- [MEDIAQ]
- Florian Rivoal. Media Queries. 19 June 2012. W3C Recommendation. URL: https://www.w3.org/TR/2012/REC-css3-mediaqueries-20120619/
- [RFC2119]
- S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. Internet RFC 2119. URL: https://www.ietf.org/rfc/rfc2119.txt
Other references
-
- [CSS1]
- Håkon Wium Lie; Bert Bos. Cascading Style Sheets (CSS1) Level 1 Specification. 11 April 2008. W3C Recommendation. URL: https://www.w3.org/TR/2008/REC-CSS1-20080411
- [CSS3-TRANSITIONS]
- Dean Jackson; et al. CSS Transitions. 12 February 2013. W3C Working Draft. (Work in progress.) URL: https://www.w3.org/TR/2013/WD-css3-transitions-20130212/
Index
- conditional group rules, 2.
- conformance
CSS
, 7.6.CSSConditionRule
, 7.3.CSSGroupingRule
, 7.2.CSSMediaRule
, 7.4.CSSSupportsRule
, 7.5.- general_enclosed, 6.
- group rule body, 3.
- group_rule_body, 3.
- media, 5.
- ‘
@media
’ rule, 5. - nested_statement, 3.
- OR, 6.
- support, 6.1.
- supports_condition, 6.
- supports_condition_in_parens, 6.
- supports_conjunction, 6.
- supports_declaration_condition, 6.
- supports_disjunction, 6.
- supports_negation, 6.
- ‘
@supports
’ rule, 6. - supports_rule, 6.
- SUPPORTS_SYM, 6.