The following is a MathML version of the WCAG 2.2 definition of relative luminance. Refer to MathML Software - Browsers for information about browsers and plugins that support MathML which you may need in order to correctly display the information on this page.
the relative brightness of any point in a colorspace, normalized to 0 for darkest black and 1 for lightest white
For the sRGB colorspace, the relative luminance of a color is defined as where R, G and B are defined as:
If then else
If then else
If then else
and are defined as:
(Formula taken from [SRGB].)
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.
Almost all systems used today to view web content assume sRGB encoding. Unless it is known that another color space will be used to process and display the content, authors should evaluate using sRGB colorspace. If using other color spaces, see Understanding Success Criterion 1.4.3.
If dithering occurs after delivery, then the source color value is used. For colors that are dithered at the source, the average values of the colors that are dithered should be used (average R, average G, and average B).
Tools are available that automatically do the calculations when testing contrast and flash.