The Word Wide Web Consortium (W3C) has a formula for the contrast ratio of any two arbitrary colors, which they use to set minimum standards for text legibility: http://www.w3.org/TR/WCAG20-TECHS/G18.html
Step 1 of the process is relatively straight-forward – it uses a well known conversion from sRGB to XYZ and keeps the Y component for the next step. Step 2 is the same for the second color.
My question comes in step 3, where the ratio is determined as
(L1 + 0.05) / (L2 + 0.05) with L1 and L2 being the luminances of the lighter and darker colors from steps 1 and 2. Where does the magic constant 0.05 come from? It’s obvious that some constant offset is needed, otherwise pure black would have infinite contrast against every other color. But how is it derived?
Also, does this contrast ratio reasonably describe how easy it is to discern text against a background? Or is there a different formula that would be better?
I ask because it seems to favor black over white – where I see better results with white text, the formula suggests black is better.
https://www.w3.org/WAI/ER/tools/ gives a list of accessibility evaluation tools which includes a contrast checker and the WAVE tool by WebAIM checks the contrast ratios along with other accessibility features.
I’d like a clearer understanding on how this is calculated.