My designer colleague just brought to my attention that he has different results for contrast from different tools. How is that possible?

He did the comparison for a ~Portage color #9E83F5 with white with the following, proven, tools:

The tools return contrast values that differ by 0.5 sometimes, which is considerable. We made sure that both tools actually got the same colour code, which is the case.

I was convinced that the algorithm was specified as part of the WCAG, and this seems the case. There even is a MathML version of the relative luminance definition

Contrast Ratio in WCAG

(L1 + 0.05) / (L2 + 0.05), where

  • L1 is the relative luminance of the lighter of the colors, and
  • L2 is the relative luminance of the darker of the colors.

the relative luminance of a color is defined as L = 0.2126 * R + 0.7152 * G + 0.0722 * B […]

the relative luminance of a color is defined as L = 0.2126 * R + 0.7152 * G + 0.0722 * B […]

My conclusion would be that one of the tools has a bug and does not conform to WCAG’s definition.

Or is there any nuance that I’m unaware of, that would explain these differences?

  • I noted this note in the specs: “Before May 2021 the value of 0.04045 in the definition was different (0.03928). It was taken from an older version of the specification and has been updated. It has no practical effect on the calculations in the context of these guidelines.” I’m not sure about the last part. Maybe code based on the old factor would return different values?
    – Andy
    Nov 14 at 15:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.