CSS gains inline conditionals and custom functions in Values & Units spec
The CSS Values & Units specification is introducing two new features: the if() conditional function and reusable custom functions that accept arguments. The if() construct allows developers to select property values inline based on media, supports, or style conditions, without duplicating selectors across multiple at-rules. Custom functions go beyond CSS variables by accepting multiple arguments, supporting default values, and encapsulating reusable logic that returns a single output. Together, these additions aim to reduce redundancy in stylesheets and make conditional styling more explicit and maintainable. The if() function is currently available in Chrome starting from version 137.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in