logoalt Hacker News

PanicAdmin • today at 1:18 PM • 1 reply • view on HN

As a non-webmaster, this is interesting. what's the math to calculate the ratio?


Replies

blululu • today at 2:48 PM

There are plenty of comprehensive guides [1], but the basic procedure is to calculate the luminance of an RGB color value (gamma corrected) and then take the ratio with the following formula:

C = (L1 + 0.05) / (L2 + 0.05)

We can get into where the model breaks (the maximum contrast ratio of text on a computer is not 21), but it should be though of in the context of the fact that a website is seen on a great variety of displays of variable quality. If the contrast ratio is close to the line it is probably over the line for someone. You should aim to be inclusive and considerate and choose a contrast ratio that is likely to be legible for the majority of viewers.

https://www.accessibility-developer-guide.com/knowledge/colo...