Post #1756604
2026-04-28 15:31 UTC
And is it even possible for CSS if() to compare two numbers? Seems not.
color: if(sibling-count() <= var(--comp): red);
(--comp is a number)
Replies (4)
-
@chriskirknielsen@front-end.social 2026-04-28 15:35
@ppk@front-end.social Maybe if you register `--comp` as a number it might work? Should be possible but I'm not certain.
-
@JaneOri@front-end.social 2026-04-28 16:00
@ppk@front-end.social idk what the multi platform etiquette is but repeating what I mentioned elsewhere, you can use math to create a comparison bit flag and use if(style(--flag: 1): red;); https://codepen.io/propjockey/pen/MYjEZYp
-
@bigandy@indieweb.social 2026-04-28 17:35
@ppk@front-end.social You can with if(style()) e.g. li { background-color: if(style(sibling-count() <= var(--comp, 10)): red); } https://codepen.io/bigandy/pen/pvNzMdw?editors=0100
-
@kizu@front-end.social 2026-04-28 19:01
@ppk@front-end.social Was resolved to have this ~a year ago, but probably not implemented anywhere as needs edits to the spec: https://github.com/w3c/csswg-drafts/issues/11104