# CSS Conditional Rules Module Level 3

## Editor’s Draft, 1 January 1970

Specification Metadata

This version:
  https://drafts.csswg.org/css-conditional-3/
Latest published version:
  https://www.w3.org/TR/css3-conditional/
Previous Versions:
  https://www.w3.org/TR/2013/CR-css3-conditional-20130404/
Test Suite:
  http://test.csswg.org/suites/css-conditional-3_dev/nightly-unstable/
Editor:
  L. David Baron (Mozilla)
Issue Tracking:
  GitHub Issues
Suggest an Edit for this Spec:
  GitHub Editor

Copyright © 1970 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and permissive document license rules apply.

## Abstract

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.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, etc.

## Status of this document

This is a public copy of the editors’ draft. It is provided for discussion only and may change at any moment. Its publication here does not imply endorsement of its contents by W3C. Don’t cite this document other than as work in progress.

GitHub Issues are preferred for discussion of this specification. When filing an issue, please put the text “css-conditional” in the title, preferably like this: “[css-conditional] …summary of comment…”. All issues and comments are archived, and there is also a historical archive.

This document was produced by the CSS Working Group.

This document was produced by a group operating under the 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.

This document is governed by the 1 March 2019 W3C Process Document.

The following features are at-risk, and may be dropped during the CR period:

- 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.

“At-risk” is a W3C Process term-of-art, and does not necessarily imply that the feature is in danger of being dropped or delayed. It means that the WG believes the feature may have difficulty being interoperably implemented in a timely manner, and marking it as such allows the WG to drop the feature if necessary when transitioning to the Proposed Rec stage, without having to publish a new Candidate Rec without the feature first.

## 1. Introduction

### 1.1. Background

This section is not normative.

[CSS21] defines one type of conditional group rule, the @media rule, and allows only style rules (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 [MEDIAQUERIES-4] section 1.

## 2. Processing of conditional group rules

This specification defines some CSS at-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.

For example, with this set of nested rules:

    @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

All conditional rules are defined to take a <stylesheet> in their block, which means they can accept any rule that is normally allowed at the top-level of a stylesheet, and not otherwise restricted. (For example, an @import rule must appear at the actual beginning of a stylesheet, and so is not valid inside of another rule.)

Invalid or unknown rules inside the <stylesheet> must be considered invalid and ignored, but do not invalidate the conditional rule.

## 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 style rule (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. Its syntax is:

    @media <media-query-list> {
      <stylesheet>
    }

It consists of the at-keyword @media followed by a (possibly empty) media query list (as defined in [MEDIAQUERIES-4]), followed by a block containing arbitrary rules. 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.

## 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 similar to that defined for <media-condition> in [MEDIAQUERIES-4]:

- 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.

- "unknown" values (neither true nor false) are needed to allow for future-compatibility, so new types of support queries can be added and treated sensibly in older UAs.

Therefore, the syntax of the @supports rule allows testing for property:value pairs, and arbitrary conjunctions (and), disjunctions (or), and negations (not) of them.

The syntax of the @supports rule is:

    @supports <supports-condition> {
      <stylesheet>
    }

with <supports-condition> defined as:

    <supports-condition> = not <supports-in-parens>
                         | <supports-in-parens> [ and <supports-in-parens> ]*
                         | <supports-in-parens> [ or <supports-in-parens> ]*
    <supports-in-parens> = ( <supports-condition> ) | <supports-feature> | <general-enclosed>
    <supports-feature> = <supports-decl>
    <supports-decl> = ( <declaration> )

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>
<supports-in-parens>

  The result is the result of the child subexpression.

not <supports-in-parens>

  The result is the negation of the <supports-in-parens> term. The negation of unknown is unknown.

<supports-in-parens> [ and <supports-in-parens> ]*

  The result is true if all of the <supports-in-parens> child terms are true, false if at least one of the <supports-in-parens> is false, and unknown otherwise.

<supports-in-parens> [ or <supports-in-parens> ]*

  The result is false if all of the <supports-in-parens> child terms are false, true if at least one of the <supports-in-parens> is true, and unknown otherwise.

<supports-decl>

  The result is true if the UA supports the declaration within the parentheses.

<general-enclosed>

  The result is unknown.

  Authors must not use <general-enclosed> in their stylesheets. It exists only for future-compatibility, so that new syntax additions do not invalidate too much of a <supports-condition> in older user agents.

The condition of the @supports rule is the result of the <supports-condition> in its prelude.

For example, the following rule

    @supports ( display: flex ) {
      body, #navigation, #content { display: flex; }
      #navigation { background: blue; color: white; }
      #article { background: white; color: black; }
    }

applies the rules inside the @supports rule only when display: flex is supported.

The following example shows an additional @supports rule that can be used to provide an alternative for when display: flex is not supported:

    @supports not ( display: flex ) {
      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 flex-based layout, so it is important that they be present only in the non-flex 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 border in a way what would cause the box to become invisible were box-shadow not supported.

    .noticebox {
      border: 1px solid black;
      padding: 1px;
    }
    @supports ( box-shadow: 0 0 2px black inset ) or
              ( -moz-box-shadow: 0 0 2px black inset ) or
              ( -webkit-box-shadow: 0 0 2px black inset ) or
              ( -o-box-shadow: 0 0 2px black inset ) {
      .noticebox {
        -moz-box-shadow: 0 0 2px black inset;
        -webkit-box-shadow: 0 0 2px black inset;
        -o-box-shadow: 0 0 2px black inset;
        box-shadow: 0 0 2px black inset; /* unprefixed last */
        /* override the rule above the @supports rule */
        border: none;
        padding: 2px;
      }
    }

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))) {
      /* ... */
    }

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: flex {
      /* ... */
    }

Instead, authors must write:

    @supports (display: flex) {
      /* ... */
    }

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: flex)) {
      /* ... */
    }

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: flex !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: 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 style rule 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 `CSSConditionRule` interface

The `CSSConditionRule` interface represents all the “conditional” at-rules, which consist of a condition and a statement block.

    [Exposed=Window]
    interface CSSConditionRule : CSSGroupingRule {
        attribute CSSOMString conditionText;
    };

`conditionText` of type `CSSOMString`
  The `conditionText` attribute represents the condition of the rule. Since what this condition does varies between the derived interfaces of `CSSConditionRule`, 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:

  1. Trim the given value of white space.
  2. 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.
  3. Otherwise, do nothing.

### 7.3. The `CSSMediaRule` interface

The `CSSMediaRule` interface represents a @media at-rule:

    [Exposed=Window]
    interface CSSMediaRule : CSSConditionRule {
        [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
    };

`media` of type `MediaList`, readonly
  The `media` attribute must return a `MediaList` object for the list of media queries specified with the @media at-rule.
`conditionText` of type `CSSOMString` (CSSMediaRule-specific definition for attribute on CSSConditionRule)
  The `conditionText` attribute (defined on the `CSSConditionRule` parent rule), on getting, must return the value of `media.mediaText` on the rule.

  Setting the `conditionText` attribute must set the `media.mediaText` attribute on the rule.

### 7.4. The `CSSSupportsRule` interface

The `CSSSupportsRule` interface represents a @supports rule.

    [Exposed=Window]
    interface CSSSupportsRule : CSSConditionRule {
    };

`conditionText` of type `CSSOMString` (CSSSupportsRule-specific definition for attribute on CSSConditionRule)
  The `conditionText` attribute (defined on the `CSSConditionRule` 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> extensibility 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.5. The `CSS` namespace, and the `supports()` function

The `CSS` namespace holds useful CSS-related functions that do not belong elsewhere.

    partial namespace CSS {
      boolean supports(CSSOMString property, CSSOMString value);
      boolean supports(CSSOMString conditionText);
    };

`supports(CSSOMString property, CSSOMString value)`, returns `boolean`
`supports(CSSOMString conditionText)`, returns `boolean`
  When the `supports(property, value)` method is invoked with two arguments property and value:

  1. If property is an ASCII case-insensitive match for any defined CSS property that the UA supports, and value successfully parses according to that property’s grammar, return `true`.

  2. Otherwise, if property is a custom property name string, return `true`.

  3. Otherwise, return `false`.

  Note: No CSS escape or whitespace processing is performed on the property name, so `CSS.supports(" width", "5px")` will return `false`, as " width" isn’t the name of any property due to the leading space.

  When the `supports(conditionText)` method is invoked

  with a single conditionText argument:

  1. If conditionText, parsed and evaluated as a <supports-condition>, would return true, return `true`.

  2. Otherwise, If conditionText, wrapped in parentheses and then parsed and evaluated as a <supports-condition>, would return true, return `true`.

  3. Otherwise, return `false`.

## Privacy and Security Considerations

This spec introduces no new security considerations.

Various features in this specification, associated mainly with the @media rule but also to some degree with the @supports rule, provide information to Web content about the user’s hardware and software and their configuration and state. Most of the information is provided through the features in [MEDIAQUERIES-4] rather than through the features in this specification. However, the @supports rule may provide some additional details about the user’s software and whether it is running with non-default settings that may enable or disable certain features.

Most of this information can also be determined through other APIs. However, the features in this specification are one of the ways this information is exposed on the Web.

This information can also, in aggregate, be used to improve the accuracy of fingerprinting of the user.

## 8. Changes

The following (non-editorial) changes were made to this specification since the 4 April 2013 Candidate Recommendation:

- Drop requirement for spaces around and, or, and not keywords for consistency with Media Queries (which are themselves constrained by compatibility with the output of some CSS minimizers that rely on some of the more arcane aspects of CSS tokenization). Note that white space--or a comment--is still required after these keywords, since without it they and the ensuing opening parenthesis will be tokenized as a function opening token.
- Allow the `supports()` method to imply parentheses for simple declarations, for consistency with the @import rule’s supports() function.
- Fixed missing semicolons in IDL code.
- Updated links, terminology, and example code in response to changes to other modules.
- Added section on privacy and security considerations.

## 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, Brad Kemper, 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.

## Conformance

### 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.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with `<strong class="advisement">`, like this: UAs MUST provide an accessible alternative.

### Conformance classes

Conformance to this specification is defined for three conformance classes:

style sheet
  A CSS style sheet.
renderer
  A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
  A UA that writes a style sheet.

A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.

A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

### Requirements for Responsible Implementation of CSS

The following sections define several conformance requirements for implementing CSS responsibly, in a way that promotes interoperability in the present and future.

#### 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 property 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.

#### Implementations of Unstable and Proprietary Features

To avoid clashes with future stable CSS features, the CSSWG recommends following best practices for the implementation of unstable features and proprietary extensions to CSS.

#### Implementations of CR-level Features

Once a specification reaches the Candidate Recommendation stage, implementers should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec, and should avoid exposing a prefixed variant of that feature.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

## Index

### Terms defined by this specification

- conditional group rule, in §2
- conditionText, in §7.2
- CSSConditionRule, in §7.2
- CSSMediaRule, in §7.3
- CSSSupportsRule, in §7.4
- @media, in §5
- media, in §7.3
- support, in §6.1
- @supports, in §6
- <supports-condition>, in §6
- supports(conditionText), in §7.5
- <supports-decl>, in §6
- <supports-feature>, in §6
- <supports-in-parens>, in §6
- supports(property, value), in §7.5
- SUPPORTS_RULE, in §7.1

https://drafts.csswg.org/css-backgrounds-3/#propdef-border Referenced in:

- 6. Feature queries: the @supports rule

https://drafts.csswg.org/css-backgrounds-3/#propdef-box-shadow Referenced in:

- 6. Feature queries: the @supports rule (2) (3)

https://drafts.csswg.org/css-cascade-4/#typedef-declaration Referenced in:

- 6. Feature queries: the @supports rule

https://drafts.csswg.org/css-cascade-4/#at-ruledef-import Referenced in:

- 1.1. Background
- 3. Contents of conditional group rules
- 4. Placement of conditional group rules
- 8. Changes

https://drafts.csswg.org/css-color-4/#propdef-color Referenced in:

- 6.1. Definition of support (2)

https://drafts.csswg.org/css-display-3/#propdef-display Referenced in:

- 6. Feature queries: the @supports rule (2)

https://drafts.csswg.org/css-syntax-3/#typedef-stylesheet Referenced in:

- 3. Contents of conditional group rules (2)
- 5. Media-specific style sheets: the @media rule
- 6. Feature queries: the @supports rule

https://drafts.csswg.org/css-syntax-3/#at-ruledef-charset Referenced in:

- 4. Placement of conditional group rules

https://drafts.csswg.org/css-syntax-3/#at-rule Referenced in:

- 2. Processing of conditional group rules

https://drafts.csswg.org/css-syntax-3/#css-parse-something-according-to-a-css-grammar Referenced in:

- 7.5. The CSS namespace, and the supports() function (2) (3)

https://drafts.css-houdini.org/css-typed-om-1/#custom-property-name-string Referenced in:

- 7.5. The CSS namespace, and the supports() function

https://drafts.csswg.org/css-values-4/#mult-zero-plus Referenced in:

- 6. Feature queries: the @supports rule (2)

https://drafts.csswg.org/css-values-4/#comb-one Referenced in:

- 6. Feature queries: the @supports rule (2) (3) (4)

https://drafts.csswg.org/css2/visudet.html#propdef-width Referenced in:

- 6. Feature queries: the @supports rule

https://drafts.csswg.org/cssom-1/#namespacedef-css Referenced in:

- 7.5. The CSS namespace, and the supports() function (2)

https://drafts.csswg.org/cssom-1/#cssomstring Referenced in:

- 7.2. The CSSConditionRule interface
- 7.5. The CSS namespace, and the supports() function (2) (3)

https://drafts.csswg.org/cssom-1/#cssrule Referenced in:

- 7.1. Extensions to the CSSRule interface

https://drafts.csswg.org/cssom-1/#medialist Referenced in:

- 7.3. The CSSMediaRule interface (2) (3)

https://drafts.csswg.org/cssom-1/#dom-medialist-mediatext Referenced in:

- 7.3. The CSSMediaRule interface

https://html.spec.whatwg.org/multipage/semantics.html#the-link-element Referenced in:

- 1.1. Background

https://infra.spec.whatwg.org/#ascii-case-insensitive Referenced in:

- 7.5. The CSS namespace, and the supports() function

https://drafts.csswg.org/mediaqueries-4/#typedef-general-enclosed Referenced in:

- 6. Feature queries: the @supports rule (2) (3) (4) (5)
- 7.4. The CSSSupportsRule interface

https://drafts.csswg.org/mediaqueries-4/#typedef-media-condition Referenced in:

- 6. Feature queries: the @supports rule

https://drafts.csswg.org/mediaqueries-4/#typedef-media-query-list Referenced in:

- 5. Media-specific style sheets: the @media rule

https://drafts.csswg.org/mediaqueries-4/#valdef-media-not Referenced in:

- 8. Changes

https://heycam.github.io/webidl/#Exposed Referenced in:

- 7.2. The CSSConditionRule interface
- 7.3. The CSSMediaRule interface
- 7.4. The CSSSupportsRule interface

https://heycam.github.io/webidl/#PutForwards Referenced in:

- 7.3. The CSSMediaRule interface

https://heycam.github.io/webidl/#SameObject Referenced in:

- 7.3. The CSSMediaRule interface

https://heycam.github.io/webidl/#idl-boolean Referenced in:

- 7.5. The CSS namespace, and the supports() function (2)

https://heycam.github.io/webidl/#idl-unsigned-short Referenced in:

- 7.1. Extensions to the CSSRule interface

### Terms defined by reference

- [css-backgrounds-3] defines the following terms:
  - border
  - box-shadow
- [css-cascade-4] defines the following terms:
  - <declaration>
  - @import
- [css-color-4] defines the following terms:
  - color
- [css-display-3] defines the following terms:
  - display
- [css-syntax-3] defines the following terms:
  - <stylesheet>
  - @charset
  - at-rule
  - parse
- [css-typed-om-1] defines the following terms:
  - custom property name string
- [css-values-4] defines the following terms:
  - *
  - |
- [CSS21] defines the following terms:
  - width
- [cssom-1] defines the following terms:
  - CSS
  - CSSOMString
  - CSSRule
  - MediaList
  - mediaText
- [HTML] defines the following terms:
  - link
- [INFRA] defines the following terms:
  - ascii case-insensitive
- [MEDIAQUERIES-4] defines the following terms:
  - <general-enclosed>
  - <media-condition>
  - <media-query-list>
  - not
- [WebIDL] defines the following terms:
  - Exposed
  - PutForwards
  - SameObject
  - boolean
  - unsigned short

## References

### Normative References

[CSS-CASCADE-4]
  Elika Etemad; Tab Atkins Jr.. CSS Cascading and Inheritance Level 4. 28 August 2018. CR. URL: https://www.w3.org/TR/css-cascade-4/
[CSS-SYNTAX-3]
  Tab Atkins Jr.; Simon Sapin. CSS Syntax Module Level 3. 20 February 2014. CR. URL: https://www.w3.org/TR/css-syntax-3/
[CSS-TYPED-OM-1]
  Shane Stephens; Tab Atkins Jr.; Naina Raisinghani. CSS Typed OM Level 1. 10 April 2018. WD. URL: https://www.w3.org/TR/css-typed-om-1/
[CSS-VALUES-4]
  Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 4. 31 January 2019. WD. URL: https://www.w3.org/TR/css-values-4/
[CSS21]
  Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. 7 June 2011. REC. URL: https://www.w3.org/TR/CSS2/
[CSS3-ANIMATIONS]
  Dean Jackson; et al. CSS Animations Level 1. 11 October 2018. WD. URL: https://www.w3.org/TR/css-animations-1/
[CSSOM-1]
  Simon Pieters; Glenn Adams. CSS Object Model (CSSOM). 17 March 2016. WD. URL: https://www.w3.org/TR/cssom-1/
[HTML]
  Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[INFRA]
  Anne van Kesteren; Domenic Denicola. Infra Standard. Living Standard. URL: https://infra.spec.whatwg.org/
[MEDIAQUERIES-4]
  Florian Rivoal; Tab Atkins Jr.. Media Queries Level 4. 5 September 2017. CR. URL: https://www.w3.org/TR/mediaqueries-4/
[RFC2119]
  S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
[WebIDL]
  Boris Zbarsky. Web IDL. 15 December 2016. ED. URL: https://heycam.github.io/webidl/

### Informative References

[CSS-BACKGROUNDS-3]
  Bert Bos; Elika Etemad; Brad Kemper. CSS Backgrounds and Borders Module Level 3. 17 October 2017. CR. URL: https://www.w3.org/TR/css-backgrounds-3/
[CSS-COLOR-4]
  Tab Atkins Jr.; Chris Lilley. CSS Color Module Level 4. 5 March 2019. WD. URL: https://www.w3.org/TR/css-color-4/
[CSS-DISPLAY-3]
  Tab Atkins Jr.; Elika Etemad. CSS Display Module Level 3. 28 August 2018. CR. URL: https://www.w3.org/TR/css-display-3/
[CSS1]
  Håkon Wium Lie; Bert Bos. Cascading Style Sheets, level 1. 13 September 2018. REC. URL: https://www.w3.org/TR/CSS1/
[CSS3-TRANSITIONS]
  David Baron; et al. CSS Transitions. 11 October 2018. WD. URL: https://www.w3.org/TR/css-transitions-1/

## IDL Index

    partial interface CSSRule {
        const unsigned short SUPPORTS_RULE = 12;
    };

    [Exposed=Window]
    interface CSSConditionRule : CSSGroupingRule {
        attribute CSSOMString conditionText;
    };

    [Exposed=Window]
    interface CSSMediaRule : CSSConditionRule {
        [SameObject, PutForwards=mediaText] readonly attribute MediaList media;
    };

    [Exposed=Window]
    interface CSSSupportsRule : CSSConditionRule {
    };

    partial namespace CSS {
      boolean supports(CSSOMString property, CSSOMString value);
      boolean supports(CSSOMString conditionText);
    };

#at-ruledef-media Referenced in:

- 1.1. Background (2) (3)
- 1.2. Module Interactions
- 5. Media-specific style sheets: the @media rule (2) (3)
- 7.3. The CSSMediaRule interface (2)
- Privacy and Security Considerations

#at-ruledef-supports Referenced in:

- 1.1. Background (2)
- 6. Feature queries: the @supports rule (2) (3) (4) (5) (6) (7) (8)
- 6.1. Definition of support (2)
- 7.4. The CSSSupportsRule interface
- Privacy and Security Considerations (2)

#typedef-supports-condition Referenced in:

- 6. Feature queries: the @supports rule (2) (3) (4) (5) (6)
- 7.5. The CSS namespace, and the supports() function (2)

#typedef-supports-in-parens Referenced in:

- 6. Feature queries: the @supports rule (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16)

#typedef-supports-feature Referenced in:

- 6. Feature queries: the @supports rule

#typedef-supports-decl Referenced in:

- 6. Feature queries: the @supports rule (2)

#dfn-support Referenced in:

- 6. Feature queries: the @supports rule

#cssconditionrule Referenced in:

- 7.2. The CSSConditionRule interface
- 7.3. The CSSMediaRule interface
- 7.4. The CSSSupportsRule interface

#cssmediarule Referenced in:

- 7.3. The CSSMediaRule interface

#csssupportsrule Referenced in:

- 7.4. The CSSSupportsRule interface

#dom-css-supports Referenced in:

- 7.5. The CSS namespace, and the supports() function

#dom-css-supports-conditiontext Referenced in:

- 7.5. The CSS namespace, and the supports() function