Benchmark · Color

Contrast methods WCAG 2 and APCA, on 16.8 million color pairs

Every color of a 16-level sRGB grid as text on every color as background: 16,777,216 pairs, each measured with the WCAG 2 contrast ratio and with APCA. Where do the two agree, and where does one pass what the other fails?

Pairs
16,777,216
Colors
4,096
Run date

Assumptions

What was compared, decided in advance

  • The sample. Every color whose red, green and blue are each one of 0, 17, 34 … 255: 4,096 colors, each as text on each as background, 16,777,216 ordered pairs. The grid is even in sRGB code values, not in perceived lightness.
  • WCAG 2. The contrast ratio of WCAG 2.2, against 4.5:1 for body text and 3:1 for large text, its AA levels.
  • APCA. APCA-W3 0.0.98G-4g, against the minimums of APCA’s Bronze Simple Mode: Lc 75 for body text, Lc 60 for other content text and Lc 45 for large text. The sign of Lc is ignored for the thresholds and used for polarity.
  • The comparisons. Three pairings, fixed before the data was looked at: 4.5:1 with Lc 75, 4.5:1 with Lc 60, and 3:1 with Lc 45.

Results

How often the two agree

Each pairing splits the 16,777,216 pairs four ways. Agreement is both pass or both fail.

Body text: 4.5:1 and Lc 75

How Body text: 4.5:1 and Lc 75 split the pairs
OutcomePairsShare of pairs
Both pass514,3603.07%
Only WCAG 2 passes1,801,54210.74%
Only APCA passes1200.00%
Both fail14,461,19486.20%
Agreement14,975,55489.26%

Body text: 4.5:1 and Lc 60

How Body text: 4.5:1 and Lc 60 split the pairs
OutcomePairsShare of pairs
Both pass1,502,3828.95%
Only WCAG 2 passes813,5204.85%
Only APCA passes218,0951.30%
Both fail14,243,21984.90%
Agreement15,745,60193.85%

Large text: 3:1 and Lc 45

How Large text: 3:1 and Lc 45 split the pairs
OutcomePairsShare of pairs
Both pass3,491,65920.81%
Only WCAG 2 passes1,312,6957.82%
Only APCA passes345,0822.06%
Both fail11,627,78069.31%
Agreement15,119,43990.12%

Findings

What the numbers say

  • Of the 2,315,902 pairs that pass 4.5:1, 1,801,542 (77.8%) measure below Lc 75, APCA’s minimum for body text. Only 120 pairs reach Lc 75 and fail 4.5:1.
  • At Lc 60 the disagreement runs both ways: 813,520 pairs pass only WCAG 2 and 218,095 pass only APCA.
  • The body-text disagreements gather on dark backgrounds: backgrounds with a relative luminance below 0.1 hold 41.8% of the pairs that pass 4.5:1 but not Lc 75, though they are 18.9% of all pairs.
  • APCA weighs polarity and WCAG 2 does not: at Lc 60, pairs only APCA passes are 2.5 times as common for light text on dark backgrounds as for dark text on light ones.

Where

Where the pairs fall

Each image plots every pair by its WCAG 2 ratio, left to right on a log scale from 1 to 21, against its APCA |Lc|, bottom to top from 0 to 112. Darker means more pairs. The gold lines are the thresholds: 3:1 and 4.5:1 across, Lc 45, 60 and 75 up.

APCA |Lc| A density plot of WCAG 2 ratio against APCA |Lc| for dark text on a light background: the pairs form a rising band, with many pairs to the right of 4.5:1 and below Lc 75. WCAG 2 ratio
Dark text on a light background
APCA |Lc| A density plot of WCAG 2 ratio against APCA |Lc| for light text on a dark background: the pairs form a rising band, with many pairs to the right of 4.5:1 and below Lc 75. WCAG 2 ratio
Light text on a dark background

The dark strip along the bottom is real: 1,647,490 dark-on-light pairs and 1,456,975 light-on-dark pairs score exactly Lc 0. APCA reports 0 for any pair below its low-contrast clip, so no pair scores above Lc 0 and below Lc 7.

Body-text disagreement by background lightness

Share of pairs on each band of background luminance that pass 4.5:1 but not Lc 75
Background luminanceShare of pairs
0.0–0.123.7%
0.1–0.23.4%
0.2–0.31.8%
0.3–0.45.5%
0.4–0.510.0%
0.5–0.615.0%
0.6–0.717.4%
0.7–0.816.3%
0.8–0.913.6%
0.9–1.09.3%

Examples

The widest disagreements

Passes WCAG 2 by the widest APCA margin #777744 text on #000000: 4.51:1, Lc -29.3.
Passes Lc 75 with the lowest WCAG 2 ratio #FFFFFF text on #777799: 4.30:1, Lc -75.2.

Reading it

What it means, and what it does not

  • WCAG 2.2 is a W3C Recommendation, and conformance to it is measured with its own ratio. APCA is a separate method, published by its author with its own guidance; it is not part of WCAG 2.2. This study measures where they differ, not which one is right.
  • A pair that passes both meets either method’s minimum. Where they disagree, look at the pair at the size it will be used: the two examples above are the kind of pair each method lets through that the other does not.

Limits

What this does not show

  • The grid is a sample, even in sRGB code values; colors used on real sites cluster differently, so the shares here are not shares of real design choices.
  • Only the simplest APCA levels are used. APCA’s fuller guidance ties Lc to font size and weight, which this study does not model.
  • Flat colors only: no transparency, gradients, images, anti-aliasing, display differences or color-vision deficiency.

Rerun it

Files and commands

The benchmark’s files
FileContentsSizeSHA-256
study.mjsThe study: computes every number on this page. Node.js only.8.2 kBc74cf7a25830…
results.jsonIts output, including the density grids.52.9 kBfbf09330be69…
density-dark-on-light.pngThe first image above.8.5 kBa7fa09dae0ea…
density-light-on-dark.pngThe second image above.9.4 kBbe633d62e54d…
SHA256SUMS.txtThe checksums of the files above.0.3 kBd18e8551f7aa…

The results and figures are CC BY 4.0: share and adapt them, with credit to Auric Artisan. study.mjs is CC0 1.0.

In a folder with study.mjs, with Node.js 18 or later; it takes a few seconds:

Terminal

node study.mjs --png=.

References

Sources

Found a mistake? Write to us and we will correct it.