How do WCAG 2.2 ratios differ from APCA perceptual contrast?
WCAG 2.2 scores any foreground and background pair symmetrically between 1.00:1 and 21.00:1 from linear sRGB luminance. By contrast, this WCAG and APCA contrast calculator computes a signed perceptual Lc value (-108 to +106) factoring in polarity, soft black clamping, and font-weight contrast sensitivity.
Relative luminance math behind 4.5:1 and 7.0:1 ratios
Under W3C Understanding WCAG 2.2 Contrast (Minimum), sRGB channels convert to linear light around the 0.04045 cutoff (c / 12.92 below, ((c + 0.055) / 1.055)^2.4 above). Relative luminance sums those components as 0.2126 * R + 0.7152 * G + 0.0722 * B.
Dividing (L_lighter + 0.05) by (L_darker + 0.05) outputs WCAG 2.2 contrast ratio. Normal copy passes Normal AA at 4.50:1 and Normal AAA at 7.00:1, while 18 pt (24 px) or 14 pt (18.67 px) bold passes Large / UI AA at 3.00:1.
Why APCA Lc accounts for polarity and font weight
Dark-mode interfaces expose a blind spot in symmetric ratios: light text on deep blue often passes WCAG 4.5:1 yet reads faintly compared with dark text on white. APCA applies a 2.4 channel curve, clamps black below 0.022, and uses asymmetric polarity exponents (0.56/0.57 vs 0.65/0.62).
Positive APCA perceptual score outputs denote Dark text on light surface, whereas negative outputs signal Light text on dark surface. Clicking Swap colors flips polarity immediately to expose that asymmetry.
Four simulated cards below the typography specimen preview shifts across Protanopia, Deuteranopia, Tritanopia, and Achromatopsia. To inspect entire dashboards rather than isolated tokens, test UI screenshots for color blindness across complete menus and charts.
WCAG 2.2 levels and APCA Lc targets compared
Legal audits in the United States and Europe enforce WCAG 2.2 ratios directly, while APCA guides typographic hierarchy during design reviews. Matching both metrics prevents readable body text from failing statutory checks or passing mathematically while still straining eyes.
| Typography or UI element | WCAG 2.2 AA | WCAG 2.2 AAA | APCA Lc tier | Typical CSS context |
|---|---|---|---|---|
| Preferred body copy | >= 4.50:1 |
>= 7.00:1 |
Lc 90+ (Preferred body) |
Long-form articles, 14–16 px regular text |
| Minimum body paragraph | >= 4.50:1 |
>= 7.00:1 |
Lc 75+ (Body copy) |
Standard product UI copy and labels |
| Fluent sub-text | >= 4.50:1 |
>= 7.00:1 |
Lc 60+ (Readable content) |
Bold captions, secondary metadata |
| Large headings | >= 3.00:1 |
>= 4.50:1 |
Lc 45+ (Large / bold) |
20px bold titles, display headlines |
| Spot and placeholders | >= 4.50:1 |
N/A | Lc 30+ (Spot / placeholder) |
Disabled states, secondary hints |
| UI borders and focus rings | >= 3.00:1 |
N/A | Lc 15+ (Non-text / border) |
Input outlines, button frames, active icons |
Note how WCAG 2.2 evaluates single contrast pairs rather than font weight lookup tables, whereas the APCA-W3 Accessible Perceptual Contrast Algorithm ties absolute |Lc| directly to font weight and pixel height. For document workflows beyond CSS tokens, run our PDF accessibility checker to audit structure tags and reading order alongside color contrast.
Fixing failing shades in OKLab with alpha compositing
When Failing muted (#94a3b8 on #ffffff, around 2.56:1) fails AA, adjusting lightness in HSL shifts perceived brightness unevenly across hues. This OKLab contrast checker adjusts perceptual lightness instead, keeping brand hues consistent while reaching accessible targets.
Preserving hue during 24-step OKLab binary search
Whenever contrast falls below 4.5:1 or 7.0:1, Closest OKLab accessible shade fixes offers Apply AA foreground, Apply AAA foreground, and Apply AA background buttons. Each fix runs a 24-iteration binary search toward L = 0 and L = 1, scaling chroma smoothly (1 - mid * 0.65) near gamut edges.
Because the search tests darker and lighter targets simultaneously, it selects whichever adjustment has smaller OKLab lightness distance |ΔL| from your starting shade. One click updates the active field and refreshes every contrast badge.
Evaluating rgba() transparency and modern OKLCH inputs
Compliant with the W3C CSS Color Module Level 4 Specification, Foreground (text / icon) and Background parse #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(), rgba(), hsl(), hsla(), hwb(), oklch(), and oklab(). Angle suffixes accept deg, turn, rad, and grad.
- Translucent foregrounds: Alpha values below
1blend directly over the resolved opaque background before computing luminance, sorgba(30, 41, 59, 0.55)reports its rendered contrast. - Translucent backgrounds: Semi-transparent backgrounds composite over
#fffffffirst before evaluating the foreground pair.
After tuning link and body colors for digital books, validate packaging files alongside CSS styling. Verify accessible ebook compliance before EU launch to catch missing EAA metadata and broken XHTML anchors.
Sampling live screenshots and exporting CSS color tokens
Hardcoded stylesheet variables often differ from real pixels after CSS opacity layers, gradients, or backdrop filters render in production. Sampling pixels directly from a browser screenshot catches hidden contrast regressions on cards, badges, and buttons.
Picking pixel colors with Set FG and Set BG
Click Sample from screenshot to draw a local image onto a scaled preview canvas (up to 520 px wide) strictly inside browser memory. Toggle Set FG or Set BG above the canvas, then click any text glyph, border, or surface pixel to read its exact getImageData RGB triplet into the active field.
Testing UI borders and exporting CSS variables
Under W3C Understanding WCAG 2.2 Non-text Contrast, interactive controls such as UI button border (>= 3:1) require at least 3.00:1 contrast against adjacent backgrounds so keyboard focus outlines and form fields stay visible. Confirm the specimen preview card clears Large / UI AA before shipping custom outline tokens.
Once your pair passes, select Copy CSS variables in the top toolbar to export accessible CSS custom properties (--color-fg, --color-bg, and calculated --color-fg-aa or --color-fg-aaa fallbacks) cleanly. If you also distribute technical manuals for low-glare reading, pair dark-theme UI styling with a dark-mode PDF color inversion workflow for printed handouts.
Tip: Check FG OKLCH and BG OKLCH after applying an AA or AAA shade fix so you can store matching
--color-fg-aatokens across light and dark themes with consistent perceptual chroma.