Wcag Color Contrast Formula. The formula for contrast ratio given in the wcag 2 0 definition can be rearranged if we know that the text will be black luminance 0 or white luminance 1. Larger text is defined as at least.
Calculate the contrast ratio using the following formula. Larger text is defined as at least. Measure the relative luminance of the background pixels immediately next to the letter using same formula.
See the definition of relative luminance in wcag 2 0 for a formula to convert from rgb space.
Before we get to the math we need to know what contrast ratio scores we are aiming to meet or exceed. The formula for contrast ratio given in the wcag 2 0 definition can be rearranged if we know that the text will be black luminance 0 or white luminance 1. To get a passing grade aa the contrast ratio is 4 5 1 for most body text and 3 1 for larger text. See the definition of relative luminance in wcag 2 0 for a formula to convert from rgb space.