Live data from Hacker News

CSS now has an if() conditional function

caniuse.com

11–20 of 245 posts

Re: CSS now has an if() conditional function

#11
post #4

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…

Just use SCSS to smear the logic across CSS automatically.

Re: CSS now has an if() conditional function

#12
post #7

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

[flagged]

> How did this happen?

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.

Re: CSS now has an if() conditional function

#13
post #4

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…

I like making static informational pages and don't know the first thing about JavaScript, so this could be handy for me.

Re: CSS now has an if() conditional function

#14
post #9

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?

If I had a time machine I would go back and ensure that DSSSL (https://en.wikipedia.org/wiki/Document_Style_Semantics_and_S...) was the standard that got up.

Re: CSS now has an if() conditional function

#15
post #12

Earlier quoted context omitted.

[flagged]

> How did this happen? 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.

[flagged]

Re: CSS now has an if() conditional function

#16
post #9

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?

If I had a time machine I would go back and ensure that DSSSL ( https://en.wikipedia.org/wiki/Document_Style_Semantics_and_S... ) was the standard that got up.

You write your markup in an xml syntax, your scripts in a C syntax, and your styles in a lisp syntax... a perfect trio.

Re: CSS now has an if() conditional function

#17
post #9

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?

If I had a time machine I would go back and ensure that DSSSL ( https://en.wikipedia.org/wiki/Document_Style_Semantics_and_S... ) was the standard that got up.

All hail the embedded Scheme interpreter to apply Style transformations!

Although I feel like we've already explored this with XSL. The XML syntax was perhaps too much to swallow.

Re: CSS now has an if() conditional function

#18
post #6

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/

Yeesh.. I've definitely tried using break-after and being disappointed it didn't work properly. The amount of hoops I had to jump through to get things to print properly on paper...

Re: CSS now has an if() conditional function

#19
post #12

Earlier quoted context omitted.

> How did this happen? 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.

[flagged]

lol. What other browser vendors? Whatwg is just google is a trench coat. Edge is chrome. Firefox is funded by Google. So I guess apple who's main contribution is being years behind and having half their stuff be broken

Re: CSS now has an if() conditional function

#20

Earlier quoted context omitted.

[flagged]

lol. What other browser vendors? Whatwg is just google is a trench coat. Edge is chrome. Firefox is funded by Google. So I guess apple who's main contribution is being years behind and having half their stuff be broken

There's this really cool site where you can see how well supported a feature is: https://caniuse.com/?search=if

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?

Post reply on HN