Frontend Developer
Contrast for frontend developers: WCAG AA vs AAA and the 4.5:1 rule
Last updated 2026-06-24
Target 4.5:1 for body text (WCAG AA) and 7:1 for accessibility-critical UI (AAA). Don't trust your eyes. Test with a contrast checker before shipping.
Contrast Checker
Contrast Ratio
Preview
Large Text
Normal text sample.
WCAG Compliance
Frontend developers shipping accessible UI need to hit WCAG AA contrast ratios: 4.5:1 for normal text, 3:1 for large text (18pt+ or 14pt bold), and 3:1 for UI components and graphics. AAA is stricter at 7:1 for normal text, but it's a stretch goal, not a legal baseline.
Why this matters for you
A common failure is gray text on white. #767676 on white is exactly 4.54:1, just barely AA. Drop to #999999 and you're at 2.85:1, a fail. Dark mode flips the problem: white text on #1a1a1a is 17.40:1 (passes AAA), and #888888 on #1a1a1a is 4.91:1, which passes AA. Always test with a contrast checker, not by eye, because ambient light and screen brightness change how contrast looks.
Which elements need which ratio
WCAG 2.1 and 2.2 set 4.5:1 for normal text and 3:1 for large text, which starts at 18pt (24px) regular or 14pt (about 18.7px) bold. Icons, input borders, focus rings and chart lines fall under the 3:1 rule for user interface components and graphics. Disabled controls, logos and pure decoration have no requirement.
Placeholder text in an active field is still text. Light gray placeholders are a common audit failure, so aim for 4.5:1 there too, or use a visible label so nobody has to rely on the placeholder.
Real colors to compare
Common neutral grays sit right on the line. #6b7280 on white is 4.83:1 and passes AA for body text. #9ca3af on white is only 2.54:1, which fails even the 3:1 large text rule. On a dark #111827 background the roles flip. #9ca3af reaches 6.99:1, while #6b7280 drops to 3.67:1 and only works for large text.
Test every state and theme
Check the default state, then hover, focus, error and selected. Text on images or gradients needs to pass at its weakest point. If you use transparency, test the color it actually blends to on the page. A theme switch means a second full pass, because a palette that passes in light mode can fail in dark mode.
Verdict
Aim for at least 4.5:1 on body text and run every color pair through a checker. Ambient light and screen brightness make contrast look better or worse than it is.
Frequently asked questions
Does placeholder text need to meet 4.5:1?
Do disabled buttons need to meet contrast requirements?
What counts as large text in CSS pixels?
Other persona guides
Related tools
Color Picker
Pick colors and convert between HEX, RGB, HSL, CMYK, and HSV formats.
Use toolText Encoding Converter
Convert between Text, Base64, Binary, Hexadecimal, and Decimal formats.
Use toolJSON Formatter
Validate, format, and minify JSON. Browse it as a tree, run JSONPath queries, compare two documents, or validate against a JSON Schema.
Use tool