You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Defining Custom Support Queries: the ''@supports-condition'' rule</h2>
1762
+
1763
+
The <dfn at-rule id="at-ruledef-supports-condition">@supports-condition</dfn>[=at-rule=] is a [=conditional group rule=] that allows authors to define and name a [=supports query=] for later reuse,
1764
+
creating a <dfn export>named supports condition</dfn>.
1765
+
This enables complex or frequently-used feature queries to be referenced by name,
1766
+
improving maintainability and readability.
1767
+
1768
+
<pre class="prod def">
1769
+
@supports-condition <<supports-condition-name>> {
1770
+
<<block-contents>>
1771
+
}
1772
+
</pre>
1773
+
1774
+
Where <dfn><<supports-condition-name>></dfn> is an <<extension-name>> that defines the name of the supports query.
1775
+
1776
+
Anything inside the block is evaluated to test whether the user agent supports the features used.
1777
+
The contents do not have any effect on the document's rendering.
1778
+
1779
+
Once defined, the named supports condition can be used in subsequent ''@supports'' or ''@when'' conditions.
1780
+
1781
+
Multiple ''@supports-condition'' rules with the same name in a style sheet are invalid and must be ignored.
1782
+
1783
+
<div class="example">
1784
+
For example, we can define a supports query checking multiple properties at once:
1785
+
<pre class="lang-css">
1786
+
@supports-condition --thicker-underlines {
1787
+
text-decoration-thickness: 0.2em;
1788
+
text-underline-offset: 0.3em;
1789
+
}
1790
+
1791
+
/* Equivalent to (text-decoration-thickness: 0.2em) and (text-underline-offset: 0.3em) */
1792
+
@supports (--thicker-underlines) {
1793
+
a {
1794
+
text-decoration: underline;
1795
+
text-decoration-thickness: 0.2em;
1796
+
text-underline-offset: 0.3em;
1797
+
}
1798
+
}
1799
+
</pre>
1800
+
</div>
1801
+
1802
+
''@supports-condition'' rules are allowed before ''@import'' and ''@namespace'' rules (after the ''@charset'' rule, if any).
1803
+
1804
+
<div class="example">
1805
+
As support queries can contain arbitrary declarations,
1806
+
they can be used to detect support for complex features such as nesting:
@@ -1874,7 +1977,7 @@ Changes since the <a href="https://www.w3.org/TR/2021/WD-css-conditional-5-20211
1874
1977
<li>Imported the definitions of <font-format> and <font-tech> from CSS Fonts 4, rather than duplicating them in this specification (<a href="https://github.com/w3c/csswg-drafts/issues/8110">#8110</a>)</li>
1875
1978
<li> Updated to use the new parsing algorithm names and block production names</li>
1876
1979
<li>Corrected a typo in the grammar of <font-format></li>
1877
-
<li>Corrected extra spaces in the font-tech and font-format productions (<a href="https://github.com/w3c/csswg-drafts/issues/7369">#7369</a>)</li>
1980
+
<li>Corrected extra spaces in the font-tech and font-format productions (<a href="https://github.com/w3c/csswg-drafts/issues/7369">#7369</a>)</li>
1878
1981
</ul>
1879
1982
1880
1983
<h3 id="changes-from-L4" class="no-num">
@@ -1889,6 +1992,7 @@ Additions since Level 4</h3>
1889
1992
<li>Moved Container Queries from [[CSS-CONTAIN-3]] to this specification.
1890
1993
(See also the [[CSS-CONTAIN-3#changes]] for more information
1891
1994
on the evolution of this feature.)
1995
+
<li>Added ''@supports-condition'' at-rule and related {{CSSSupportsConditionRule}} interface.
0 commit comments