910: If Statements in CSS?
Jun 11, 2025•25 min
Summary
Wes and Scott explore the new CSS if() function, discussing its syntax, current browser support (Chrome 137+), and how it allows for conditional logic directly in CSS properties using variables and attributes. They demonstrate use cases like theming and button states, compare it to traditional CSS classes and JavaScript, and touch upon its integration with media queries and the broader trend towards declarative CSS APIs.Episode description
Wes and Scott talk about the new If statements in CSS, breaking down how they work, why they matter, and when to use them. They explore use cases, syntax quirks, and how this feature pushes CSS closer to true conditional logic—no JavaScript required.
Show Notes- 00:00 Welcome to Syntax!
- 01:30 Brought to you by Sentry.io
- 02:37 CSS If statements in action
- 09:08 Advanced examples and the attribute function
- 13:43 Mixing If statements with media queries
- 16:54 Can’t this be done with classes?
- 18:16 The future of CSS: declarative APIs
- 21:10 Is CSS now a programming language?
Syntax: X Instagram Tiktok LinkedIn Threads
Wes: X Instagram Tiktok LinkedIn Threads
For the best experience, listen in Metacast app for iOS or Android
