hhmx.de

Föderation EN Di 13.05.2025 20:50:11

Have you ever wished the browser would look at a background color and pick black or white for the text — whichever one provides more contrast? Now, the `contrast-color()` function in CSS does just that.

webkit.org/blog/16929/contrast

Föderation EN Di 13.05.2025 21:47:11

@jensimmons Nighty new feature. Also, I was delighted by the in-depth discussion about choosing colors for accessibility. Thanks for calling that out!

Föderation EN Di 13.05.2025 21:56:50

@ngaylinn @jensimmons

You may find this of interest - I use this a lot;

medialab.github.io/iwanthue/

Föderation EN Di 13.05.2025 23:01:22

@jensimmons Because feedback was requested:

I will not use this until a better contrast calculation algorithm has been implemented. APCA has been shown to be superior in every real-world test I have seen. While I'm happy that you've indicated willingness to replace it later, I would have loved to see more leadership from the Webkit team. Please adopt a superior contrast scoring method (APCA) instead of a demonstrably broken algorithm that is divorced from how we perceive colour and contrast.

Föderation EN Di 13.05.2025 23:30:03

@jensimmons This is so cool. Is there any info about where this is in the standards process? I had trouble finding much info about it, so I assume it’s still early days?

Föderation EN Mi 14.05.2025 00:37:36

@estoner Oh it’s fully specified:
w3.org/TR/css-color-5/#contras

This version that choses between black/white that is.

Föderation EN Mi 14.05.2025 01:37:08

@jensimmons Aha! That helps, thank you.

I’m having trouble finding any record of it in places like caniuse and MDN; is it too early for that, or would it be files under something other than “contrast-color”?

Föderation EN Mi 14.05.2025 01:40:09

@estoner It's not too early to be on MDN / in MDN BCD or in Can I Use. It’s just that no one has added it yet. (Git PR on GitHub to the open source project(s) will do it.)

Föderation EN Di 13.05.2025 23:31:56

@jensimmons Would love to see the Messages team show this same interest in contrast ratios, since it's well documented that green texts have an accessibility-unfriendly contrast ratio while blue ones don't, presumably a cynical play to increase the unattractiveness of green texts.

Föderation EN Di 13.05.2025 23:42:58

@jensimmons is that first s a typing error?

Föderation EN Mi 14.05.2025 00:35:54

@mjr Yes. Thanks! And thankfully I can fix it on Mastodon.