Title: CSS Conditional Values Module Level 1 Shortname: css-conditional-values Level: 1 Status: UD ED: https://drafts.csswg.org/css-conditional-values-1/ Group: csswg Work Status: exploring Editor: Lea Verou, Invited Expert, http://lea.verou.me/about, w3cid 52258 Abstract: This module explores additions to CSS to enable conditional values. Repository: w3c/csswg-drafts Default Highlight: css Inline Github Issues: title Warning: Not ReadyIntroduction {#intro} ===================== This section is not normative. Note: This section is a stub and needs to be expanded. Authors frequently need to set a property to different values based on the relation between certain values. High level custom properties {#high-level-custom-properties} ----------------------------- A web component may support several custom properties which do not contain a value fragment verbatim, but set several properties across multiple rules indirectly. For example, a `--size` property with values `small`, `medium`, `large`, or an `--alignment` property with values `horizontal` and `vertical`. Relation between units of the same type {#relation-between-units} --------------------------------------- Author code often needs to branch based on the relation between different units of the same type. For example: * Comparing viewport and absolute units allows compact one-off viewport dimension media queries * Comparing font-relative units and absolute <
<boolean-constant> = 'true' | 'false'Logical comparisons: The <
<condition> = not <Note: A future version of this module may expand <> | < > [ and < > ]* | < > [ or < > ]* <condition-in-parens> = ( < > ) | < > <atomic-condition> = < > < > < > | < > <comparison-operand> = < > | < > | < > | < > <comparison-operator> = [ '=' | '>=' | '>' | '<' | '<=' ]
<Issue: How can authors specify consequents or antecedents that include commas? Alternative syntax that addresses this, though may be hard to read when consequent/antecedent are keywords:> = if( < >, < > [, < >]?) <consequent> = < > <antecedent> = < >
<> = if( < > then < > [else < >]?) < > = < > < > = < >
flex-flow: if(100vw > 500px, row, column);
background: if(var(--raised) = on, linear-gradient(white, transparent)) hsl(200 100% 50%);
font-size: if(var(--size) = small, 2em) if(var(--size) = medium, 3em) if(var(--size) = large, 5em)