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.
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.
@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.
@estoner Oh it’s fully specified:
https://www.w3.org/TR/css-color-5/#contrast-color
This version that choses between black/white that is.
@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”?