Frontend Development”>Joab Jackson”>CSS Finally Implements New If ( ) Functions for Inline Conditional Logic. – The New Stack
What non-React equipment do you use the most frequently as a Script designer?
✓
Angular
0%
✓
Astro
0%
✓
Svelte
0%
✓
Vue.js
0%
✓
Other
0%
✓
I only employ Respond.
0%
✓
I don’t employ JavaScript.
0%
2025-10-17 08: 00: 59
CSS Finally Implements New If ( ) Functions for Inline Conditional Logic.
For the first time ever, prominent line conditional logic is introduced to stylesheets. What does it mean for engineers, and how it works.
At All Things Open 2025, Mark Adkins discusses the most recent CSS developments ( TNS photo ).
Inline contingent processing is becoming available for CSS.
Those who have been a little clung in by the declaration of the internet’s general style sheets will soon have a little more room to experiment.
Devs and designers have been asking for decades whether CSS had any conditional logic, and they have only discovered solutions in and abroad. The technical committee behind the style standard has now approved a new function for the style sheet, if ( ), which opens up a whole new world of options for designers.
In a talk about some of the most recent developments with at the meeting in Raleigh, N. C. earlier this week, , a deputy user experience designer at financial firm Fidelity Investments, said,” This is the first moment, that I’m aware of, that you can do this reasoning line without having a dedicated code block on the bottom of your file.
The ( W3C), which oversees the development of web pages, uses CSS as the standard method for specifying the presentation, design, and layout of those pages, combining HTML with HTML to provide page setup and JavaScript for page logic.
CSS is a mature systems, so it doesn’t receive as many updates as it once did. W3C publishes a snapshot once a year that combines all the most recent changes across various areas of the specification ( last month’s edition was posted ). The computer developers are then responsible for seeing these specifications implemented, whose progress has been diligently monitored by the website.
What is the CSS if ( ) Function?
The new performance, which will be available in the 2025 snapshot, is CSS’s first.
Adkins admitted to the visitors,” This one actually caught me off guard.
The standard doesn’t offer much in the way of reasoning processing, whereas the majority of CSS deals with shading, coloring, and other important aspects of presentation.
Adkins said if ( ) builds on previous work to make it possible for developers to specify variables or” .” With JavaScript, the properties created in the browser’s Document Object Model ( ) can be modified.
The new features incorporates reasoning properties directly into the inline code.
The if ( ) work itself is nothing new in the world of programming; most important languages have their own implementation. The Browser if… more function, and , provides a way for the programmer to established different values of a property based on the results of a provisional test. If a follows x, if b follows y, and so on.
If none of the conditions are met, you may also provide an additional statement.
The test  on a , a , or a in the context of CSS.
How does the CSS if ( ) Function function work?
The statement consists of an ordered semi-colon-separated list of statements, each containing a condition and a value, separated by a colon, according to .
The function’s syntax can be seen here as purloined Mozilla Development Network documents:
Below, you will find that one of two background images can be deployed on a web page depending on the theme chosen ( “ice” or “fire” ): MDN also provides an example of how if ( ) could be used:
According to Adkins, the function can be included in any property of a class or as a component of a selector.
Current Browser Support and Adoption
The if function is currently only partially supported by some browsers.
Browser support for the CSS if ( ) function, as of October 2025. this source?
The function is supported by Chrome and Edge, but Safari and Firefox continue to lag behind. Only Google for Android and the other two browsers, which support mobile development, recognize this statement, which drags even further.
As of October 2025, mobile browsers have implemented the CSS if function. ? Source:  .
New Opportunities With CSS Conditionals
In outlining the ways the new conditional could be used, Google Web UI DevRel Lead wrote that the addition of if “provides a new architectural opportunity for CSS developers.
Kravets suggested that inline media queries be made with the function. As an illustration, a website could alter its layout depending on the user’s preference for light or dark mode. It could also be used to perform inline support checks, evaluating whether the hardware supports the design, and converting to an alternative design if necessary. It might be useful for displaying the state of a running process, with various images indicating whether or not the task has been completed.