diff --git a/css-cascade-5/Overview.bs b/css-cascade-5/Overview.bs index 0c1d6a4e1e9..daa5995e33c 100644 --- a/css-cascade-5/Overview.bs +++ b/css-cascade-5/Overview.bs @@ -129,7 +129,7 @@ Importing Style Sheets: the ''@import'' rule as if they were written literally into the stylesheet at the point of the ''@import''. Any ''@import'' rules must precede all other valid at-rules and style rules in a style sheet - (ignoring ''@charset'' and @layer statement rules) + (ignoring ''@charset'', ''@supports-condition'', and @layer statement rules) and must not have any other valid at-rules or style rules between it and previous ''@import'' rules, or else the ''@import'' rule is invalid. The syntax of ''@import'' is: diff --git a/css-conditional-5/Overview.bs b/css-conditional-5/Overview.bs index 092040c737d..f734cfd57d3 100644 --- a/css-conditional-5/Overview.bs +++ b/css-conditional-5/Overview.bs @@ -13,6 +13,7 @@ Editor: L. David Baron, Google https://www.google.com/, https://dbaron.org/, w3c Editor: Elika J. Etemad / fantasai, Apple, http://fantasai.inkedblade.net/contact, w3cid 35400 Editor: Chris Lilley, W3C, https://svgees.us/, w3cid 1438 Editor: Miriam E. Suzanne, Invited Expert, https://www.miriamsuzanne.com/who/, w3cid 117151 +Editor: Lea Verou, Invited Expert, https://lea.verou.me/about, w3cid 52258 Abstract: This module contains the features of CSS for conditional processing of parts of style sheets, based on capabilities of the processor or the environment @@ -78,7 +79,7 @@ Introduction CSS Conditional Level 5 extends the ''@supports'' rule and [=supports query=] syntax - to allow testing for supported font technologies. + to allow testing for custom support conditions as well as supported [=at-rules=] and font technologies. It also adds an ''@when'' rule, which generalizes the concept of a conditional rule. @@ -117,12 +118,20 @@ Extensions to the ''@supports'' rule <supports-feature> = <> | <> | <> | <> - | <> + | <> + <supports-decl> = ( [ <> | <> ] ) <supports-font-tech-fn> = font-tech( <> ) <supports-font-format-fn> = font-format( <> ) <supports-at-rule-fn> = at-rule( <> ) + : <> + :: + The result is true if the UA + supports the named condition. + If the name is not recognized, + the result is false. + : <> :: The result is true if the UA @@ -148,8 +157,6 @@ Extensions to the definition of support Font techs and formats - at-supports-font-format-001.html - at-supports-font-tech-001.html js/CSS-supports-L5.html @@ -179,6 +186,13 @@ At-rules Note: Because ''@charset'' is not a valid [=at-rule=], it is not considered to be supported under this definition. +

+Named conditions

+ + A CSS processor is considered to + support a named condition + when the related [=named supports condition=] returns true. +

Generalized Conditional Rules: the ''@when'' rule

@@ -1743,13 +1757,86 @@ Container Relative Lengths: the ''cqw'', ''cqh'', ''cqi'', ''cqb'', ''cqmin'', ' +

+Defining Custom Support Queries: the ''@supports-condition'' rule

+ +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. + +
+	@supports-condition <> {
+	  <>
+	}
+	
+ + Where <> is an <> that defines the name of the supports query. + + Anything inside the block is evaluated to test whether the user agent supports the features used. + The contents do not have any effect on the document's rendering. + + Once defined, the named supports condition can be used in subsequent ''@supports'' or ''@when'' conditions. + + Multiple ''@supports-condition'' rules with the same name in a style sheet are invalid and must be ignored. + +
+ For example, we can define a supports query checking multiple properties at once: +
+		@supports-condition --thicker-underlines {
+		  text-decoration-thickness: 0.2em;
+		  text-underline-offset: 0.3em;
+		}
+
+		/* Equivalent to (text-decoration-thickness: 0.2em) and (text-underline-offset: 0.3em) */
+		@supports (--thicker-underlines) {
+		  a {
+		    text-decoration: underline;
+		    text-decoration-thickness: 0.2em;
+		    text-underline-offset: 0.3em;
+		  }
+		}
+		
+
+ + ''@supports-condition'' rules are allowed before ''@import'' and ''@namespace'' rules (after the ''@charset'' rule, if any). + +
+ As support queries can contain arbitrary declarations, + they can be used to detect support for complex features such as nesting: +
+		@supports-condition --nesting {
+		  & { }
+		}
+
+		@import url("nested-styles.css") supports(--nesting);
+		
+
+ +
+ Support queries can also be used to detect support for at-rules: +
+		@supports-condition --stuck-container-feature {
+		  @container scroll-state(stuck: top) { }
+		}
+
+		@supports (--stuck-container-feature) {
+		  div { border-color: navy; }
+		}
+		
+
+ + Issue: The name of the at-rule is under discussion. + Alternatives include ''@supports-query'', ''@supports-test'', and ''@custom-supports''. + The name should be consistent with the one chosen for custom media queries. +

APIs

The CSSContainerRule interface

- The {{CSSContainerRule}} interface represents a ''@container'' rule. + The {{CSSContainerRule}} interface represents an ''@container'' rule.
 	[Exposed=Window]
@@ -1805,6 +1892,23 @@ The CSSContainerRule interface
 	When measuring layout sizes, it behaves Similar to resizeObserver,
 	but it provides the additional Container Query syntax and features.
 
+

+The CSSSupportsConditionRule interface

+ + The {{CSSSupportsConditionRule}} interface represents an ''@supports-condition'' rule. + +
+	[Exposed=Window]
+	interface CSSSupportsConditionRule : CSSGroupingRule {
+		readonly attribute CSSOMString name;
+	};
+	
+ +
+
name of type CSSOMString +
This attribute is the name of the [=named supports condition=]. +
+

Security Considerations

No security issues have been raised against this document @@ -1835,18 +1939,17 @@ Changes since the #10544) - +
  • Dimensional query containers no longer apply layout containment + (#10544)
  • Extended [=supports queries=] to express [=at-rule=] capabilities via ''at-rule()''. (#2463, #6966, #11116, - #11117) -
  • + #11117) +
  • Added ''@supports-condition'' at-rule and related {{CSSSupportsConditionRule}} interface. + (#12622)
  • @@ -1855,7 +1958,7 @@ Changes since the #10874) +
  • Added ''@container/stuck/none''-keywords to scroll-state() features (#10874)
  • Added container-type:scroll-state, and scroll-state() queries for stuck, snapped, and scrollable features (#6402, #10784, @@ -1874,7 +1977,7 @@ Changes since the #8110)
  • Updated to use the new parsing algorithm names and block production names
  • Corrected a typo in the grammar of <font-format>
  • -
  • Corrected extra spaces in the font-tech and font-format productions (#7369 )
  • +
  • Corrected extra spaces in the font-tech and font-format productions (#7369)
  • @@ -1889,6 +1992,7 @@ Additions since Level 4

  • Moved Container Queries from [[CSS-CONTAIN-3]] to this specification. (See also the [[CSS-CONTAIN-3#changes]] for more information on the evolution of this feature.) +
  • Added ''@supports-condition'' at-rule and related {{CSSSupportsConditionRule}} interface.

    Acknowledgments

    @@ -2045,7 +2149,6 @@ Additions since Level 4 js/CSS-supports-CSSStyleDeclaration.html js/CSS-supports-L3.html js/CSS-supports-L4.html - js/CSS-supports-L5.html js/CSS-supports-selector-detecting-invalid-in-logical-combinations.html js/conditional-CSSGroupingRule.html js/supports-conditionText.html