CSS finally gets support for if() function

https://www.techzine.eu/news/devops/135681/css-finally-gets-support-for-if-function/

After years of developer frustration and questions on online forums, it’s finally happening: CSS is getting an if() function to apply styling when a condition is met. For the first time, developers can make logical decisions directly in stylesheets, without separate code blocks. This opens up whole new possibilities for web designers.

104 points · 19 comments · view on lemmy.world

19 Comments

trolololol@lemmy.world · 15 pts · 292d (1 reply)

What an abomination

I'm just curious what kind of bad code is going to be around when this gets widespread.

python@lemmy.world · 3 pts · 291d

No worries, we really bad web developers have all switched to React long ago 😎 So no CSS here, just Material-UI's "sx" attribute plastered over every single component.

mormund@feddit.org · 15 pts · 292d

Only in Chromium for now. Also I don't see how it adds any new capabilities? I guess it is a little nicer syntax wise in some cases, but I might still prefer SCSS nested declarations instead.

fox2263@lemmy.world · 9 pts · 292d (1 reply)

It should be like CSS5 by now with all the stuff they’ve added

phneutral@feddit.org · 1 pts · 292d

After CSS3 they switched to rolling releases and dropped any numbers, AFAIK.

phneutral@feddit.org · 7 pts · 292d

This breaks with the foundations of CSS. You already can build if-like statements especially since the implementation of custom properties. It doesn’t have to be that explicit — quite the contrary: putting if() into every property will make them bloated and harder to understand.

fubarx@lemmy.world · 6 pts · 292d

Slow-walk to plain scripting.

SatyrSack@quokk.au · 6 pts · 292d (3 replies)

When was the last time a feature this huge was added to CSS?

0xDREADBEEF@programming.dev · 13 pts · 292d

CSS Nesting

.foo {
    .nested {
        property: value;
    }
}
ClassifiedPancake@discuss.tchncs.de · 10 pts · 292d

@container and @scope were pretty big in my opinion.

Kissaki@programming.dev · 4 pts · 291d

Quite regularly, tbh.

MadMadBunny@lemmy.ca · 5 pts · 292d

O.M.G. Finally!!!!

monogram@feddit.nl · 4 pts · 292d (1 reply)
[ removed ]
XiberKernel@lemmy.world · 5 pts · 291d

I would argue grid, :has(), var(), and native nesting have been just as important steps forward.

sik0fewl@lemmy.ca · 3 pts · 292d

JSSS had this 30 years ago!

30p87@feddit.org · 2 pts · 292d (4 replies)

what

30p87@feddit.org · 1 pts · 292d (3 replies)

When <if cond="true"></if> and <set var="x" val="lol">?

TeamAssimilation@infosec.pub · 11 pts · 292d

Can’t wait to have business logic in my CSS!

4am@lemmy.zip · 4 pts · 292d (1 reply)

That is HTML not CSS

30p87@feddit.org · 3 pts · 292d

Yeah, that's the point... CSS has conditionals now, so when will we get HTML conditionals and variables?