Image guidesPractical guides

Does readable grey text pass? Check contrast without rounding the ratio

A minimum text contrast decision needs the foreground, background and text size, rather than a visual impression alone. Two similar opaque sRGB greys on white sit on opposite sides of the 4.5:1 threshold for ordinary text.

Physical colour cards arranged in a circle on a white surface
Illustrative photo: Andy Brown · Unsplash License

Key Takeaways

For ordinary text on white, #777777 is approximately 4.478089:1 and falls below 4.5:1; #767676 is approximately 4.542225:1 and reaches that threshold. Compare unrounded values. This evaluates one text-colour condition, not the accessibility of an entire page.

In this article

Identify the text condition you are evaluating

W3C’s explanation of WCAG 2.2 contrast minimum gives an AA threshold of 4.5:1 for ordinary text and 3:1 for large text. Large text means at least 18pt, or at least 14pt bold. A visually prominent heading does not automatically qualify. These examples use opaque sRGB text on solid white.

A dominant photo colour is not automatically a suitable text colour. The palette role guide explains that distinction. The separate task here is evaluating a specific foreground and background against a text threshold.

Two similar greys produce different decisions

These are original colour fixtures recalculated from W3C’s formula, not a usability experiment or preference survey. #777777 has three channels equal to 119; #767676 has three equal to 118. White is 255,255,255. Use the actual assigned colours rather than an arbitrary blended anti-aliased edge pixel.

The computed ratios are approximately 4.478089453577214 and 4.542224959605253. W3C’s threshold explanation says not to round before comparison. Displaying 4.478 as 4.5 at one decimal place does not make it reach the threshold.

Opaque ordinary text on white
Text colourApproximate contrastOrdinary-text 4.5:1 threshold
#7777774.478089:1Below threshold
#7676764.542225:1Reaches this criterion
#FFFFFF1:1Below threshold
#00000021:1Reaches this criterion

Calculate relative luminance instead of averaging RGB

W3C’s relative-luminance definition divides 8-bit sRGB channels by 255, then linearizes them with the 0.04045 breakpoint. Luminance is 0.2126R+0.7152G+0.0722B. Contrast is the lighter luminance plus 0.05 divided by the darker luminance plus 0.05. An RGB average is a different quantity.

This JavaScript accepts only six-digit opaque sRGB samples without # and does not validate input. Compare the original value with 4.5. A rounded display for readers should not alter the decision.

Recalculate #777777 against white

const L = hex => {
  const c = hex.match(/[a-f\d]{2}/gi).map(v => parseInt(v, 16) / 255)
    .map(v => v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);
  return 0.2126*c[0] + 0.7152*c[1] + 0.0722*c[2];
};
const ratio = (a,b) => (Math.max(L(a),L(b)) + 0.05) / (Math.min(L(a),L(b)) + 0.05);
const value = ratio("777777", "ffffff");
console.log(value, value >= 4.5); // 4.478089453577214, false
Original calculation example; excludes transparency, gradients, image backgrounds and other colour spaces.

Use conversion to confirm the input, not to certify contrast

Enter #777777 into the colour format converter to confirm RGB 119,119,119. The current tool outputs HEX, RGB and HSL, not a WCAG contrast ratio. Successful conversion is not a pass. Use the confirmed pair with a checker implementing the same definition, or recalculate with the example.

For screenshot-derived colours, distinguish solid areas from transparent edges and background blends; see image colour sampling and edge checks. A different background, opacity, size or weight changes what needs checking.

Return from the solid-colour fixture to the real page

#767676 reaches the minimum in this example only for the stated white-background, ordinary-text condition. Photos and gradients require the background actually behind the text to be evaluated. Translucent text requires the composited colour. The raw HEX alone does not settle those cases.

Review the rendered text, and assess links, focus indicators and status communication separately. A contrast pass does not establish content quality, keyboard access or whole-site conformance. Record the pair, text size and weight, unrounded ratio, standard and page location.

Further reading & sources

Put the guide into practice

Open the relevant tool, preview the result and check your exported file.