Ag17.40:1
Normal vision
Trichromatic
Pass · AA 4.5:1
Color pair in, WCAG verdict out
Type a HEX, RGB or HSL value for the text and the background, or pick a color from the wheel. ColorContrastLab computes the WCAG 2.2 relative luminance and contrast ratio, shows AA and AAA results for normal text, large text and UI components, simulates five kinds of color vision, and exports the pair as CSS custom properties or Tailwind tokens. Nothing is uploaded; the math happens on this page.
Text color
#1A1A1A
Background color
#FFFFFF
Color vision
Roughly one in twelve men and one in two hundred women have a color-vision deficiency. The cards above recolor your current pair for each type and recalculate the ratio, so you can see where a passing design stops being readable.
Simulation uses the Machado, Oliveira & Fernandes (2009) matrices at severity 1.0, applied in linear light, and then recomputes contrast from the simulated colors. It is a design aid, not a diagnosis of anyone's vision.
The L-cone is missing, so red and green collapse toward the same dark yellow-brown. Reds darken sharply; dark red text on black almost disappears. About 1% of men.
The M-cone is missing, the most common type in men (about 1 in 20). Green text on red, and the classic red/green status pair, lose their difference.
The S-cone is missing: blue and green merge, and yellow can look pink or gray. Rare, and not sex-linked.
Only luminance remains. Contrast is exactly what this reader has left, which is why a solid ratio helps more than hue does.
Palette
Save a checked pair, then collect text and background colors to compare every combination at once. Saved pairs and palette colors feed the export below.
Each pair keeps its own text, background and opacity.
No saved pairs yet. Check a pair above, name it if you like, and press Save.
Every color you add is tested as text and as background against every other.
No palette colors yet. Add the text or background color to build a matrix.
Add at least two colors and every combination appears here, row by row.
Rows are text colors, columns are backgrounds. AAA = 7:1 or more, AA = 4.5:1 or more, AA-L = large text and UI only (3:1), — = below 3:1.
Export
The current pair, your saved pairs and the palette become CSS custom properties, a Tailwind config, or CSS v4 @theme tokens. Copy the text or download the file — both are generated in this tab.
/* ColorContrastLab — CSS custom properties
Current pair: #1A1A1A on #FFFFFF = 17.40:1
*/
:root {
--fg: #1A1A1A; /* text */
--bg: #FFFFFF; /* background */
}
Drop the block into any stylesheet and use var(--fg) on text, var(--bg) on the surface. Saved pairs become .pair-N classes you can put on a component.
:root {
--fg: #1A1A1A;
--bg: #FFFFFF;
}Extend the theme with the pair and palette so text-fg on bg-bg, or bg-palette-2, works in class names. Tailwind v3 reads this file as tailwind.config.js.
colors: {
fg: "#1A1A1A",
bg: "#FFFFFF",
}In Tailwind CSS v4 the tokens live in CSS. Paste the @theme block into your stylesheet and Tailwind generates the utilities for you.
@theme {
--color-fg: #1A1A1A;
--color-bg: #FFFFFF;
}Export covers the current pair, saved pairs and palette colors only; nothing is fetched or signed. Check the printed comment above each token if you need to know what ratio it was chosen for.
How it works
No settings to learn: the ratio updates as you type.
Type HEX, RGB or HSL, use the wheel, or start from a sample. Lower the opacity to see how transparency changes the result.
The big number is the contrast ratio. Five badges check normal text, large text and UI components against the AA and AAA lines.
One click moves the text — and, only if it must, the background — to the nearest color that passes, keeping the hue and saturation.
Look at the pair through four color-vision deficiencies, then copy or download the CSS and Tailwind tokens.
The formula
ColorContrastLab uses the relative luminance definition in WCAG 2.2 (which is numerically identical to WCAG 2.1 for 8-bit colors) and composites transparency the way CSS paints it.
Each sRGB channel is divided by 255 and linearized, because luminance is not gamma-encoded. The three linear channels are weighted 0.2126 red, 0.7152 green and 0.0722 blue — the coefficients that follow the human eye's sensitivity — and summed into the relative luminance L.
The contrast ratio puts the lighter luminance over the darker one, adds 0.05 to both (the flare term that keeps the ratio finite for black), and divides. The result runs from 1:1 for identical colors to 21:1 for pure black on pure white.
Worked example: #767676 on #FFFFFF gives L1 = 1.0000 and L2 = 0.1812, so (1.0000 + 0.05) ÷ (0.1812 + 0.05) = 4.54:1 — just past the 4.5:1 AA line, and well short of 7:1.
Thresholds
AA is the level most policies and laws reference; AAA is stricter and usually applied to body text where it is practical.
| Text or element | Minimum ratio | Success criterion |
|---|---|---|
| Normal text under 18 pt (24 px), or under 14 pt (18.66 px) bold | 4.5:1 | AA · 1.4.3 Contrast (Minimum) |
| Normal text, AAA | 7:1 | AAA · 1.4.6 Contrast (Enhanced) |
| Large text: 18 pt (24 px) and up, or 14 pt (18.66 px) bold and up | 3:1 | AA · 1.4.3 |
| Large text, AAA | 4.5:1 | AAA · 1.4.6 |
| UI components: borders, icons, focus rings, form outlines | 3:1 | AA · 1.4.11 Non-text Contrast |
| Logos, decorative text, disabled controls | no requirement | Exempt from 1.4.3 and 1.4.11 |
Point sizes are CSS pt at 96 dpi: 18 pt = 24 px, 14 pt = 18.66 px. Bold means a font weight of at least 700 in most interpretations. Ratios are not rounded by WCAG, so 4.49:1 fails 4.5:1.
Questions
4.5:1 for normal text at AA, 3:1 for large text and UI components, and 7:1 or 4.5:1 respectively if you are aiming at AAA. If you only remember one number, remember 4.5:1 for body text.
Contrast is about luminance, not hue. Pure red (#FF0000) and pure green (#00FF00) are obviously different colors, yet red on white is only 4.00:1 and red on green is 1.28:1. The eyes of a reader with low vision or a color-vision deficiency have less to work with than yours.
It keeps the hue and saturation of the text color and moves lightness in 0.1% steps, both darker and lighter, and takes the nearest value that meets the target. If no text color can reach the target on that background — a mid-gray background cannot support 7:1 — it moves the background as little as possible and then picks the text color.
It is the AA floor for text, not a guarantee. Font size, weight, spacing, state changes and the reader's own settings all matter, and AAA (7:1) is noticeably easier to read. Use 4.5:1 as the minimum and go higher for body copy where you can.
A transparent color is painted over what is behind it, so the effective color is a mix. The tool composites the text over the background, and the background over white, exactly as CSS does, then measures the mix. 50% black on white is #808080, which is only 3.95:1.
They recolor the same pair using published protanopia, deuteranopia, tritanopia and achromatopsia matrices and recalculate the ratio from the simulated colors. A pair that passes for you can drop below 4.5:1 for a reader with deuteranopia — that is the pair you need to fix.
No. The colors, saved pairs and exports are handled in this tab. The only network request is the Google AdSense loader in the page head; blocking it does not affect the checker. Saved pairs live in your browser's local storage until you clear them.
Yes. The Tailwind config tab produces a theme.extend.colors block for tailwind.config.js (v3 and the v4 compatibility layer), and the @theme tab produces CSS custom properties for Tailwind CSS v4. The CSS variables tab is framework-free.
Limits
The checker measures the two colors you give it. It does not crawl your site, inspect rendered text, or know which pixels sit behind a transparent element.
Passing AA here does not certify a page. Accessibility also needs keyboard access, semantics, labels, motion and zoom behavior, and WCAG 2.2 adds focus appearance and target size.
The matrices approximate one severity of each deficiency. Real color vision varies, and monitor calibration changes the colors you see while checking.
Links, visited links, placeholder text and disabled states each need their own pair. Check them one by one.
Over a gradient or a photo the ratio changes pixel by pixel. Sample the lightest and darkest points, or put a solid scrim behind the text.
Saved pairs stay in this browser only. Clearing site data removes them, and they are not synced between devices.