To calculate contrast ratio the following formula is used (source):

(L1 + 0.05) / (L2 + 0.05)


L1 is the relative luminance of the lighter of the colors, and

L2 is the relative luminance of the darker of the colors.

My question is, what is the number 0.05 in this formula?


The Gamma correction and RGB constants are derived from the Standard Default Color Space for the Internet (sRGB), and the 0.05 offset is included to compensate for contrast ratios that occur when a value is at or near zero, and for ambient light effects. - http://juicystudio.com/article/luminositycontrastratioalgorithm.php


Well, without it, if L2 is darkest black, which has a relative luminance of 0, the ratio would be undefined since you can't divide by zero.

So they decided to add a small factor to make sure the ratio is always defined. The consequence of using 0.05 is that the maximum ratio is 1.05 : 0.05 = 21 : 1.

Note 1: Contrast ratios can range from 1 to 21 (commonly written 1:1 to 21:1).

Why they chose exactly this number, I have no idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.