logoalt Hacker News

CSS now has an if() conditional function

59 pointsby aanthonymaxlast Sunday at 12:21 AM23 commentsview on HN

Comments

themafiatoday at 1:37 AM

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?

show 3 replies
culitoday at 1:41 AM

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/

show 1 reply
xnxtoday at 2:15 AM

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?

show 2 replies
stevefan1999today at 1:39 AM

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

mr_windfrogtoday at 3:42 AM

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?

aanthonymaxlast Sunday at 12:21 AM

This support has appeared in the new W3C specification.

zb3today at 1:45 AM

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..

show 1 reply