- Give it enough time, every declarative language becomes a programming language. This is happening with all config files, markup languages, data formats.
The distinction between code, config and data is being erased. Everything is a soup now. Data is application, configuration is code. Code is an intermediate, volatile thing that is generated on the fly and executed in the temporary lambda containers.
- Far from being ready when only one major browser supports it. If you want this, you should vote for it to be focused on for interop-2026
https://github.com/web-platform-tests/interop/issues
Right now, the leading CSS proposals are `@container style()`, `corner-shape` and `break-after`
https://foolip.github.io/interop-reactions/
- I'm pretty happy to see this, as conditionals can really help keep code manageable when trying to define CSS variables or other properties based on combinations of light mode, dark mode, high-contrast, contextual state in a document or component, etc.
if() isn't the only way to do this, though. We've been using a technique in Review Board that's roughly equivalent to if(), but compatible with any browser supporting CSS variables. It involves:
1. Defining your conditions based on selectors/media queries (say, a dark mode media selector, light mode, some data attribute on a component, etc.).
2. Defining a set of related CSS variables within those to mark which are TRUE (using an empty value) and which are FALSE (`initial`).
3. Using those CSS variables with fallback syntax to choose a value based on which is TRUE (using `var(--my-state, fallback)` syntax).
I wrote about it all here, with a handful of working examples: https://chipx86.blog/2025/08/08/what-if-using-conditional-cs...
Also includes a comparison between if() and this approach, so you can more easily get a sense of how they both work.
- It's a great way to make conditional styles without having to use JavaScript; however, having used JS for years to make theme color and icon sets that rely on CSS properties, I'm not sure I particularly like this method. I feel like you have to smear a lot of logic across your CSS whereas with JS you can reduce your theme to a data structure and just have a simple function to setup all the CSS variables based on that.
Am I just an old man?
by EmilStenstrom
1 subcomments
- Here is a much better link to how it works: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/V...
by bingemaker
2 subcomments
- I'm not sure turning CSS into a full blown language is a good idea. With all the cascading in place, it is already a bit hard to determine why certain styles are applied. Now with this, we will be spending more brain cells debugging CSS issues.
- Not supported in Firefox and Safari. Also it seems most people forget that the more bloated the web platform is, the more resources are needed to develop and maintain a web browser engine.. Chromium is open-source, but it's already expensive to maintain a fork or even rebuild it..
by stevefan1999
2 subcomments
- With the inclusion of branches, is it possible to say that CSS is now even more Turing-Complete? Now we just need to find ways to do recursion/targeted jumps so that it is finally recursive-enumerable
- If we could do it over, knowing that we'd eventually get to this point, would https://en.wikipedia.org/wiki/JavaScript_Style_Sheets have been the better path?
by Incipient
3 subcomments
- As long as css remains "so fast it's free" then I'm mostly happy with that - I use css without thinking about optimisations, and I like it like that!
by Pwntastic
1 subcomments
- just a meta note that the submitter, aanthonymax, likely only posted this to launder karma to avoid being shadowed for spamming their github project. a quick look at their post history shows that they only post links to their github project and then occasionally extremely low effort random mdn or other useless links to try to balance our their account. their previous account was shadowed for basically the same thing
- https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/V...
- So we were looking in the wrong direction for AGI!
- Huh. 35 year ago I was the sole maintainer of an in-house SQL-like database query language. The application was transforming relational data into a more concise and efficient format for use in an embedded application (AT&T 5ESS digital switch). All the mapping was done in this SQL-like language. One of my power users mentioned the difficulty they had in actually changing logic based on the values in the database. For example, to perform different logic based on whether a column was a 1 or a 2, they'd have to write two querys: one for 1 and another for 2. Possible, sure, but not very clean or efficient. To address this, I implemented an if() function.
- It's a working draft and only available in Chromium ...
by marcinignac
0 subcomment
- Proposed title change "Chrome now has an if() conditional function in CSS"
- Can it already vertically and horizontally center unknown-beforehand-length multi-line text in a single html element, just like non-CSS table cells could already in 1995?
by manucardoen
0 subcomment
- Somewhere, someone has just started porting Doom to CSS.
by mr_windfrog
2 subcomments
- I'm not really sure I understand this. How is the new if() conditional function different from using @media (width ...) when adapting layouts to browser width?
by trollbridge
0 subcomment
- One of the nice things working in vite is realising, “hey, this config file is just {Java,Type}Script”.
- If I'm reading this correctly, Opera added support in an earlier version then took it away again. Any idea why they might have done it? Maybe a browser engine change under the hood?
- Haven’t seen this mentioned yet, but this means you can do media queries in inline styles, right?
- I guess we can now write Excel in CSS.
by silverwind
1 subcomments
- This is missing a "if variable equals" imho. Right now it seems like pure syntactic sugar for a media query.
- Is it Turing-complete yet? Seems close, but I've lost track.
by shevy-java
0 subcomment
- They want to turn it into a programming language ... :/
by qwertytyyuu
0 subcomment
- oh no, this is going to cause abomninations,
- Can these be used inside inline style attributes?
by moritzwarhier
0 subcomment
- I'm kind of thankful not having to work with people trying to be clever in CSS anymore (especially "clever" backend developers).
And I used to defend and evangelize taking HTML&CSS seriously in my previous roles, which I'd still do!
But as much as I have longed for features like these in the past (also: :has(), container queries, custom properties...), I dislike this.
I found CSS grid disappointing for most use cases.
I think :has() is a terrible idea, except for quick hacks.
I still think container queries and custom properties are good.
But, oh well, old man yelling at cloud.
- Quick, someone get DOOM running on CSS!
- Nice, does it make turing complete? If so, another crap to block under Dillo.
That's what happens when you design a language by comitee (C++, JS) and try to do
stuff in the web for a platform made to share static documents.
Just look at what kind of disasters the users faced with Office macros.
- How long before CSS can run Doom?
- How about giving me the option to use variables in media queries?
- Not supported in Firefox
- if (it's fast) {
i'm excited
}
by aanthonymax
0 subcomment
- This support has appeared in the new W3C specification.
by phplovesong
1 subcomments
- Now we just need a while loop to make it turing complete.
- Next I want to run WASM inside CSS. W3C, please don’t disappoint.
- [dead]
- Nice. I've built desktop apps in a few other frameworks e.g. Java Swing, JavaFX, JetBrains Compose, SwiftUI, QT. Nothing is as easy as JS/HTML/CSS. I've realized that the main reason is its robust capabilities e.g rich auto-layouting/positioning capabilities.
Meanwhile in other UI frameworks, you either don't do it or you draw the damn things yourself lol. So, most of the times I'd just not do it.
Adding if is great. It would reduce the need for JS a bit more, which would make the code more maintainable.