CSS Now Has an If() Conditional Function
Postedabout 1 month agoActive23 days ago
caniuse.comTech Discussionstory
informativepositive
Debate
20/100
CSSWeb DevelopmentBrowser Compatibility
Key topics
CSS
Web Development
Browser Compatibility
Discussion Activity
Very active discussionFirst comment
N/A
Peak period
147
Day 6
Avg / period
26.7
Key moments
- 01Story posted
Nov 29, 2025 at 7:21 PM EST
about 1 month ago
Step 01 - 02First comment
Nov 29, 2025 at 7:21 PM EST
0s after posting
Step 02 - 03Peak activity
147 comments in Day 6
Hottest window of the conversation
Step 03 - 04Latest activity
Dec 10, 2025 at 12:21 PM EST
23 days ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
ID: 46092198Type: storyLast synced: 11/30/2025, 12:38:07 AM
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
Am I just an old man?
Edited: It seems it can also be toggled from css variable? So it might actually fix some existing problems.
Considering the kinds of crap that have been done with headers...
The paths of least resistance on the web are now very different. These features were not delayed due to implementation details, but a deliberate shepherding of the standards. The most powerful features were saved for later and even still this is scoped to media queries, etc. only.
And, maybe, in a TTF font.
CSS if() probably just merges one of two single-property RuleSets onto the parent RuleSet depending on the condition, which has nothing to do with branching, as there is no execution flow to branch.
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/
Unfortunately the test set of wpt does not have the capability to cover printed matter so relief isn't coming any time soon
Anybody know how that compares to Report Definition Language?
https://learn.microsoft.com/en-us/sql/reporting-services/rep...
Seems like an awfully scattered shitshow just to arrive at a typical "What You See Is Not What You Get" result.
And this one is made for printouts.
https://github.com/w3c/csswg-drafts
That's pretty simple - Google has poured tons of money into Chrome and Mozilla. Google is not a charity so this was a strategic investment.
> You should go over to the CSS working group and let them know
That wouldn't work, money is what ultimately matters there.
If Google controls everything, why is if() only supported on 59% traffic? Do you think any serious company will let their site break on 40% of clients? Do you think Apple's opinion is unimportant?
When there's a conflict of interest they don't (Apple refuses to implement some APIs that would help making their walled garden app store more obsolete). But just maintaining a duopoly (Mozilla is funded by Google) is not a conflicting interest itself.
> Did you come to that opinion after engaging in the discussions with them?
With employees? There's no point. If you have a well paid job you will never accept the fact that what you're doing might not be so good after all..
What makes you think Apple wants to maintain any sort of duopoly? Do you think they're happy that Edge became a Chrome skin?
> With employees? There's no point. If you have a well paid job you will never accept the fact that what you're doing might not be so good after all..
Damn, so you haven't even tried discussing your issues with the people responsible? You seem to have a really strong opinion on something you haven't engaged with at all.
That's not going to happen.
They can't break millions of websites by removing old features. Besides, for the most part, current developers can ignore most of the old stuff.
But a site made in 1997 has to render on current browsers.
1: https://hacks.mozilla.org/2017/08/inside-a-super-fast-css-en...
So in that sense CSS + HTML + User Interaction is Turing complete. But that is a different language then CSS, even if a part of that language happens to be written in CSS.
EDIT: For the record, while I am very impressed, and this is a wonderful work of art we can all enjoy, I am not convinced this is proof of the Turing completeness of CSS. At most this would prove that CSS + HTML is Turing complete (which still better then CSS + HTML + User instructions in natural language). But I wonder if in these 43000 lines of CSS the entire state space was encoded (with some clever compression obviously), and I am not sure if that would count as proof of Turing completeness.
CSS alone is not Turing-complete (AFAIK), because you don't have anywhere to attach state (the computed style) if you don't have a DOM and loops are generally prohibited. But CSS exists literally only to style a DOM, so I don't consider that all that much of a concession.
Although I feel like we've already explored this with XSL. The XML syntax was perhaps too much to swallow.
And honestly we already essentially have this with CSS related apis in js. The examples in that article are basically identical to how you set css in js on modern web browsers with slightly different naming conventions.
I think if can also do string equality on variable values, which is a bit new but also niche. The main point is just to do @media but inside a property decleration.
CSS is confusing because the vast majority of web developers never learned it properly. Many developers won't learn any "new" CSS (like CSS Grid which shipped in all browsers in 2017) beyond the hacks they learned in the '90s and early 2000's.
That's not the fault of CSS.
Disagree. The newer stuff is, if anything, more confusing. The old stuff, awful as it was, at least had a consistent model.
With the "old stuff", we didn't a layout model or an alignment model. Everything required float and positioning hacks to do things they weren't designed to do. There's no logical way that was "better."
There were several different grid systems, all mostly incompatible with each other, which were required to do anything interesting.
Many layouts that are common today were impossible to do with just HTML & CSS back in '90s and 2000's.
Capabilities that almost all developers had to reach for a framework Bootstrap or Foundation for are built-in to CSS today. Or lots of JavaScript.
I will kiss the feet of the whatwg groups if they do this.
PS: Would also love to have declarative template inclusion now that removal of XSLT has also removed this facility from the browser.
This is exactly what it does not need. SASS style conditional CSS is a complete nightmare to maintain. The declarative nature is one of its greatest strengths.
if(style(--foo: bar): baz)
Is how you test if variable --foo is equal to "bar"
See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/V...
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.
https://en.wikipedia.org/wiki/Harvard_architecture
That said, I'm unaware of any programming language (outside assembler) that takes that split to heart in a higher-level way.
If you want to reason that the hardware is at fault, you should be blaming the Eckert-Mauchley architecture.
- Puppet
- CMake
- Terraform
- ...
All these started with pure declarative DSL then incrementally created a nightmarish imperative monstrosity.
I guess the answer to your question is OCaml has unmanaged side effects.
Ant came first, then when Microsoft redid the VS project format, they created MSBuild.
As incredible as it may sound, Ant is still easier to deal with than MSBuild.
If you understood the paradigm, you could write branches in Ant files simply using properties and guards on properties ("unless"). Using IF in Ant was basically admission of not having understood Ant.
This said, I used Ant for a very limited amount of time.
https://ant.apache.org/manual/Tasks/condition.html
The else part is easily done by repeating and negating the condition.
Two other advantages of Ant that MSBuild lacks in a sane way to this day, are macros, and proper documentation.
https://ant.apache.org/manual/ifunless.html
I always liked Ant, as I don't suffer from XML allergy.
Also you forgot MSBuild is used for everything, not only .NET.
Never seen any big corp using alternative .NET build tools, rather wrestling MSBuild, or before it came to be, nmake.
Makes reading it even harder, and any possible constraints due to type safety go out of the window, so we get worst of both worlds.
CMake today is effectively an eso-lang / Turing tarpit with some “modern” declarative conventions that people try to push.
"Huh?" I asked myself when you mentioned that Terraform is now imperative somehow. Took a look at the website again, and seems to still be HCL, and still be declarative. Am I missing something? How exactly is Terraform today a "imperative monstrosity"?
This is not necessarily a problem except that they had to live in the original HCL v1 landscape which makes them awkward syntactically.
... What? How is modules a function call? It's just a hierarchy, everything about/with modules is still declarative.
> HCL 2 has loops and conditionals. It is most definitely imperative.
So what? Just because there is loops and conditionals doesn't mean it's suddenly imperative.
How exactly you do loops in HCL? Last time I used it, you still used declarative configuration for that, and use `for_each` as an declared option, you don't "call for_each which returns config", all that happens inside of HCL/TF, because it is declarative.
Did something change like yesterday or are people even here on HN so ignorant about what declarative vs imperative actually means?
I don't understand why there is a distinction between for each in a standard language vs for_each in HCL2. They are both do something by iterating over something else at runtime. The syntax isn't what matters here.
I think maybe you are mistaken in your own distinction between declarative and imperative.
Declarative: Tell the computer what you want the result to be like, and the computer figures out how to do it.
for_each in Terraform is very much declarative, just like modules. Compare how you'd do the same thing with JS or any other (imperative) language you know, and I think it must be clear what the difference between the two is.
I have read terraform modules where I had to execute the logic to know what got produced which moves it from your imperative description to the declarative description as far as I'm concerned.
Cost.
If money were no object, you would only hire people who can troubleshoot the entire stack, from React and SQL all the way down to machine code and using an oscilloscope to test network and power cabling.
Or put another way, it would be nice for the employer if your data analyst who knows SQL also knew C and how to compile Postgres from scratch, so they could fully debug why their query doesn’t do what they expect. But that’s a more expensive luxury.
Good software has declarative and imperative parts. It’s an eternal tradeoff whether you want the convenience of those parts being in the same codebase, which makes it easier to troubleshoot more of the stack, but that leads to hacks that break the separation. So sometimes you want a firm boundary, so people don’t do workarounds, and because then you can hire cheaper people who only need to know SQL or React or CSS or whatever, instead of all of them.
Then time passes, edge cases start cropping up and hacks are bolted on to accommodate them. Eventually everything struggles under the weight of not having loops, conditionals, etc. and those are added.
After some time, the cycle begins anew.
A programming (i.e Turing complete) language requires recursion or a construct of equal power.
Overly pessimistic, lots of non-programming languages remain non-programming languages. Just because one of the most widely used declarative languages start adding conditionals doesn't mean the whole world is turning upside down...
> The distinction between code, config and data is being erased.
As as lisp programmer, I love it. Get rid of treating things differently, make everything the same and make everything work with everything, code should just be data.
You need to look at a large terraform project.
> As as lisp programmer, I love it.
You make bad engineering decisions because you consider the advantages, but not the disadvantages. <https://news.ycombinator.com/item?id=29231493>
Fun way of having a conversation.
The question still is: why is CSS becoming a programming language? And who decides on this, anyway?
I mean looking at the mdn docs it's just a replacement for regular other syntax https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/V...
So instead of having a css for x which defines e.g. dark mode and light mode separately, you can now define it via a single css rule.
Where previously the "tree" forked at the beginning and attributes were set multiple times, depending on various criteria - now you set it once, and evaluate it's value depending on criteria
It looks like simple syntactic sugar to meBut instead of a single unified standard library for the industry we got a sprawling, ludicrous mess of multiple poorly thought-out semi-compatible technologies, with an associated sub-industry of half-baked fixes and add-ons.
The context is also lost. Javascript was famously coded in a day or whatever and called 'javascript' not ecmascript as marketing to compete with Java. Besides that well known case there's presumably thousands of esoteric business decisions made back then which shaped the "sprawling, ludicrous" landscape, and which are now lost to time.
Yes, the web should have always been a programming language. And the flying cars of 23xx should have never used a z-debuffer doodad.
I'm glad the transition to mobile web accelerated on more battery efficient GPUs was possible due to the model instead of Alan Kay's idea that websites should render themselves, where each website would have needed to be upgraded for GPU support for compositing.
Efficient evaluation of expressions is a solved problem.
Having conditionals would actually improve performance because you can use fewer rules.
What I see in the SO answer is an interface for Rule 110 with an additional set of instruction (written in a natural language) for the user to execute manually. So you can use CSS + HTML to create an interface for a Rule 110, which is then written in a natural language around that interface. The answer even states that (very relevant) caveat.
> [...] so long as you consider an appropriate accompanying HTML file and user interactions to be part of the “execution” of CSS.
> The formal definition (simplest) of Turing Machine is simply a tuple of states set, symbol set, initial state, accepting states set and a transition function. There is no crank in it. By computation we mean somebody needs to apply the transition function faithfully on the tape which is exactly like the clicking in this case. More formally, a model of computation can be viewed as a set of rules somebody needs to follow to do the computation. In that sense, I think CSS is Turing-Complete.
There is even a "CPU emulation" in pure CSS: https://dev.to/janeori/expert-css-the-cpu-hack-4ddj
https://mikehadlow.blogspot.com/2012/05/configuration-comple...
This distinction never existed in LISP. Greenspun's tenth rule in action.