3 properties, 6 at-rules, 2 functions defined by this
specification, 6 of them known to at least one browser
(the others are badged Not in any browser yet).
<div class="card"> <div class="post-meta"> <h2>Card title</h2> <p>My post details.</p> </div> <div class="post-excerpt"> <p> A preview of my <a href="https://example.com">blog post</a> about cats. </p> </div></div>
Syntax
none | <custom-ident>+
Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Definition
Initial
none
Applies to
all elements
Inherited
no
Percentages
n/a
Computed value
the keyword none, or an ordered list of identifiers
Canonical order
per grammar
Animation type
not animatable
Browser support
First browser version supporting container-name
Chrome
105
Edge
105
Firefox
110
Safari
16
Chrome Android
105
Safari iOS
16
First version with support, from MDN browser-compat-data.
<div class="container"> <div class="card"> <h3>Normal card</h3> <div class="content"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </div> </div></div><div class="container wide"> <div class="card"> <h3>Wider card</h3> <div class="content"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </div> </div></div>
Spec The @container rule is a conditional group rule whose condition contains a container query, which is a boolean combination of container size queries and/or container style queries. Style declarations within the @container rule are filtered by its condition to only match when the container query is true for their element’s query container.
MDN The @containerCSSat-rule is a conditional group rule that applies styles to a containment context. Style declarations are filtered by a condition and applied to the elements within the container if the condition is true. The condition is evaluated when the queried container size, <style-feature>, or scroll-state changes.
Live previewExample from MDN
span { display: block; text-align: center;}.card { margin: 10px; border: 2px dotted; font-size: 1.5em;}.post { border: 2px solid;}/* A container context based on inline size */.post { container-type: inline-size;}/* Apply styles if the container is narrower than 650px */@container (width < 650px) { .card { width: 50%; background-color: lightgray; font-size: 1em; }}
Spec The @else rule is a conditional group rule used to form conditional rule chains, which associate multiple conditional group rules and guarantee that only the first one that matches will evaluate its condition as true. It is defined as:
Syntax
@else <boolean-condition>? { <rule-list> }
Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Spec The @media rule is a conditional group rule whose condition is a media query. Its syntax is:
MDN The @mediaCSSat-rule can be used to apply part of a style sheet based on the result of one or more media queries. With it, you specify a media query and a block of CSS to apply to the document if and only if the media query matches the device on which the content is being used.
Live previewExample from MDN
abbr { color: #860304; font-weight: bold; transition: color 0.5s ease;}@media (hover: hover) { abbr:hover { color: #001ca8; transition-duration: 0.5s; }}@media not all and (hover: hover) { abbr::after { content: " (" attr(title) ")"; }}
<p> <abbr title="National Aeronautics and Space Administration">NASA</abbr> is a U.S. government agency that is responsible for science and technology related to air and space.</p>
Syntax
@media <media-query-list> { <rule-list> }
Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.
Browser support
First browser version supporting @media
Chrome
1
Edge
12
Firefox
1
Safari
3
Chrome Android
18
Safari iOS
1
First version with support, from MDN browser-compat-data.
Spec 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. These queries are called CSS feature queries or (colloquially) supports queries.
MDN The @supportsCSSat-rule lets you specify CSS declarations that depend on a browser's support for CSS features. Using this at-rule is commonly called a feature query. The rule must be placed at the top level of your code or nested inside any other conditional group at-rule.
Spec The @supports-condition at-rule is a conditional group rule that allows authors to define and name a supports query for later reuse, creating a named supports condition. This enables complex or frequently-used feature queries to be referenced by name, improving maintainability and readability.
Spec The @when at-rule is a conditional group rule that generalizes the individual conditional group rules such as @media and @supports. It is defined as:
Syntax
@when <boolean-condition> { <rule-list> }
Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.