- Introduced by
- W3C Accessibility Guidelines
- Year
- 2018
- Type
- Measurement and compliance assessment
- Family
- Accessibility and visual clarity
What does it do?
Contrast Ratio Measurement quantifies the luminance difference between two colours, typically a foreground text colour and its background, as a single ratio.
The ratio is computed from relative luminance and compared against the thresholds in the WCAG 2.1 accessibility guidelines. It measures luminance contrast only, so it is a check on brightness difference rather than a complete test of legibility.
The intuition behind the method
Readability of text depends largely on how far its brightness differs from the background, whether the text is dark on light or light on dark. The contrast ratio expresses this brightness difference as one number, which can be compared against WCAG thresholds. Because the ratio is defined on relative luminance, it ignores hue: two colours of different hues but similar brightness score low even if they look distinct to most viewers. A high ratio is therefore helpful for readability but does not establish it on its own. Insufficient contrast makes text harder to see, which matters especially for users with low vision.
History
The ratio used in practice is defined in the W3C Web Content Accessibility Guidelines (WCAG) 2.1 (2018), which sets the thresholds used on this page. The relative luminance formula used here is the one defined in that specification; readers who need the derivation of its coefficients should consult the W3C documentation directly. Current use extends beyond web content to print, signage and other visual media.
When to use it
Use this method when checking text, or essential graphical elements, against a background in interfaces, documents or slides, particularly where WCAG conformance is required. It suits brand palettes and data-visualisation labels where readability depends on brightness difference. Apply it as an early check during design and again on the final rendered output. Do not use it as the only test for colour-vision deficiency, since it does not assess hue discrimination. Do not treat a passing ratio as proof of legibility under glare or on poor displays. For text over images, measure the least favourable region rather than an average.
Limitations and considerations
- The ratio uses relative luminance only and ignores hue, so a colour pair that passes the threshold can still be hard to distinguish if the difference lies mainly in hue, which matters for some colour-blind users.
- The WCAG thresholds assume a typical viewing context; glare, display quality and ambient light change the effective contrast a reader experiences, and the ratio does not model them.
- A passing ratio says nothing about aesthetic quality or visual hierarchy.
- Stroke width is not part of the calculation, so for thin typefaces the ratio alone may overstate legibility.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Gives an objective numeric measure of luminance contrast that anyone can recompute from the same colour values.
- Maps directly onto the WCAG 2.1 conformance thresholds, so results can be reported against a named standard.
- Requires only two colour values and the luminance formula, so it can be computed with simple tools.
- Provides a quick screening step that can be run on every colour pair in a palette before user testing.
Applications
- Web and digital design: ensuring text meets WCAG accessibility standards across pages
- Document and print design: validating readability of reports, books, and printed materials
- User interface design: checking that UI text, labels, and buttons are readable for all users
- Data visualization: ensuring chart labels and legends are legible at intended viewing distances
- Signage and wayfinding: verifying text clarity on public signage and navigation aids
- Inclusive design practices: evaluating entire digital products for accessibility across diverse vision abilities
How it works
How it works
Identify the two colours to compare, normally the foreground (text) colour and the background colour, as they will appear in the rendered design.
Convert each colour (RGB, hex or another format) to sRGB channel values scaled to the 0–1 range. Linearise each channel with the piecewise sRGB transfer function specified in WCAG 2.1, which applies a linear segment near black and a power-law segment elsewhere, so that the luminance weights in the next step act on linear values.
Compute relative luminance as L = 0.2126 × R + 0.7152 × G + 0.0722 × B, using the linearised channel values. Then compute the contrast ratio (L_lighter + 0.05) / (L_darker + 0.05); the offset keeps the ratio at or above 1 and avoids division by zero for black.
Compare the ratio with the WCAG 2.1 thresholds: AA requires 4.5:1 for body text and 3:1 for large text, while AAA requires 7:1 for body text and 4.5:1 for large text. Record which text and background pairs fall below the applicable threshold, and recommend a lighter or darker colour for each failing element. A passing ratio does not test hue, so it should not be the only check.
Common pitfalls
- Treating WCAG AA compliance as sufficient for critical content; AAA thresholds are stricter, and user testing remains necessary.
- Using colour alone to distinguish elements; supplement colour with text labels, patterns or icons so the information survives a loss of hue or brightness difference.
- Checking contrast only on a calibrated design monitor under ideal lighting; the effective contrast on lower-quality or brightly lit screens may be lower.
- Measuring a single colour pair when the background is an image, uses transparency or is affected by anti-aliasing; the effective contrast then varies across the text and should be checked at its least favourable point.
Frequently asked questions
What is the minimum contrast ratio I should use?
WCAG 2.1 AA requires 4.5:1 for normal body text and 3:1 for large text. AAA requires 7:1 for body text and 4.5:1 for large text. Large text is defined in WCAG 2.1 by size and weight, and 18pt is only one part of that definition, so check the exact criteria in the WCAG 2.1 text before applying the lower threshold. For critical safety or medical content, consider aiming for AAA. Where possible, also test with real users.
Does color contrast help color-blind users?
Luminance contrast (brightness difference) helps colour-blind users, whereas relying on hue alone, such as red versus green, does not. Provide high luminance contrast and supplement colour information with text labels, patterns or symbols.
How do I test contrast if I use background images?
With background images, measure contrast against the lightest and darkest areas of the image separately, and test where the text sits over the least favourable region. A semi-transparent overlay can help give more consistent contrast across the image.
Can I achieve accessibility with color alone?
No. Do not rely on colour alone to convey information. Provide sufficient luminance contrast and supplement it with text, symbols or patterns.
Related methods
Sources
World Wide Web Consortium (2018). Web Content Accessibility Guidelines (WCAG) 2.1. https://www.w3.org/WAI/WCAG21/quickref/
Open publication referencePoynton, C. (2012). Gamma FAQ: Frequently Asked Questions about Gamma. http://poynton.ca/GammaFAQ.html
Open publication referenceLegge, G. E., Pelli, D. G., Rubin, G. S., & Schleske, M. M. (2007). Psychophysics of Reading—I. Normal Vision. Vision Research, 25(2), 239–252.
Open DOI reference