Design, before Any SoftwareLesson 37 of 74

Module 4 · Colour, measured

What a contrast checker is actually computing

In this lesson

  • 9 min read
  • 4 reading sections
  • Knowledge check
  • Lesson 3 of 11 in this chapter

This chapter’s goalBuild a palette from perceptual lightness ramps rather than from hue, state the contrast ratio of every text pair and the criterion it is being judged against, name the specific conditions under which that ratio overstates legibility, and give any colour-carried meaning a second non-colour encoding.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmWatch2:30Not available
Full audiobookNot availableNot available
How to check a contrast ratioLineariseConvert each sRGBchannel using the0.04045 cutoff.Weight and sumMultiply red by0.2126, green by0.7152 and blue by0.0722.Take the ratioAdd 0.05 to eachluminance and dividethe larger by thesmaller.CompareUse the unroundedresult and thethreshold for thatuse.Identical colours produce 1:1. Black and white produce 21:1. Use the colours from the actualforeground and background.
Identical colours produce 1:1. Black and white produce 21:1. Use the colours from the actual foreground and background.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 6Free · no account needed
Lesson steps

From screen values to relative luminance

The WCAG 2.2 contrast ratio for sRGB colours ranges from 1:1 to 21:1. The formula compares two relative luminances. Colour values such as an RGB channel of 128 must be converted before they can represent light.

Divide each 8-bit red, green and blue channel by 255. Apply the WCAG sRGB conversion separately to each result.

Text
c_lin = c / 12.92                  when c <= 0.04045
c_lin = ((c + 0.055) / 1.055)^2.4   otherwise

The published cutoff is 0.04045. Some older references show 0.03928. Then apply the luminance weights and compare the lighter and darker luminances.

Text
L = 0.2126 × R_lin + 0.7152 × G_lin + 0.0722 × B_lin
ratio = (L_lighter + 0.05) / (L_darker + 0.05)

Black against white gives 1.05 divided by 0.05, or 21:1. Identical colours give 1:1, including black against black. The 0.05 term is fixed. The checker never measures the light falling on your screen.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Meher, your AI tutor

How to cite: Addaly (2026) ‘What a contrast checker is actually computing’, in Design, before Any Software. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/design-foundations/the-contrast-ratio-formula (Accessed: 29 November 2026).