Light gray text on a white background looks elegant – and is barely readable for many people. This doesn’t only affect people with visual impairments: older readers, anyone with a reflective screen or anyone looking at their phone in bright sunlight also needs sufficient contrast.
The Web Content Accessibility Guidelines (WCAG) define measurable minimum values for this. This guide explains how the contrast ratio is calculated, which values apply to text and UI components and how to fix colors that are too weak without giving up your design.
What the contrast ratio means
The calculation is based on a color’s relative luminance, its perceived brightness between 0 (black) and 1 (white). The color channels are weighted differently: green looks much brighter to the human eye than blue, so green accounts for just over 70 % of the result and blue for just over 7 %. The contrast ratio is derived from the luminance of the lighter color (L1) and the darker color (L2):
contrast = (L1 + 0.05) / (L2 + 0.05)
The result ranges from 1:1 (identical colors) to 21:1 (black on white). A few examples on a white background:
| Text color | Contrast on #FFFFFF | Result for normal text |
|---|---|---|
#999999 | 2.85:1 | insufficient |
#777777 | 4.48:1 | just short |
#767676 | 4.54:1 | meets AA |
#595959 | 7.00:1 | meets AAA |
The thresholds are strict: 4.48:1 is not rounded up to 4.5:1. The Color Contrast Checker (WCAG) calculates the exact value for your color combination and shows which level it reaches. The complete formula is in the definition of relative luminance in WCAG 2.2.
The WCAG 2.2 requirements
1.4.3 Contrast (Minimum) – Level AA
- Normal text: at least 4.5:1
- Large text: at least 3:1
Text counts as large from 18 points (about 24 px) or from 14 points bold (about 18.66 px). Level AA is the level that laws and standards usually refer to.
1.4.6 Contrast (Enhanced) – Level AAA
- Normal text: at least 7:1
- Large text: at least 4.5:1
AAA is rarely required for an entire website, but it is a good target for long passages of body text.
1.4.11 Non-text Contrast – Level AA
UI components and graphics also need at least 3:1 against adjacent colors. This covers:
- borders of input fields, checkboxes and buttons when they are the only thing that makes the component visible,
- states such as focus, selected or “checked”,
- icons without a text label and parts of charts that are needed to understand them.
A typical example: an input field with a #CCCCCC border on white only reaches 1.61:1. With #949494 it is 3.03:1 – the field stays subtle but is still recognizable. You can check both text and UI components of your color scheme with the Color Contrast Checker (WCAG). The W3C provides explanations with examples in Understanding 1.4.3 and Understanding 1.4.11.
Exceptions
No minimum contrast applies to logos and brand names, inactive components (such as a disabled button), purely decorative elements and text that is invisible or only incidentally part of an image. Text in graphics that conveys information, on the other hand, counts like normal text.
The legal situation
The European Accessibility Act (EAA) has applied since 28 June 2025. Each EU member state has transposed it into national law – in Germany, for example, through the Barrierefreiheitsstärkungsgesetz (BFSG). It covers certain consumer products and services, including many online shops and other e-commerce services; micro-enterprises providing services are exempt. Public sector bodies have been subject to separate rules for longer, in Germany for example the BITV 2.0 at federal level.
In practice, the European standard EN 301 549 serves as the technical benchmark, and it refers to the WCAG level AA criteria – so the contrast values above are part of it. Whether and to what extent the rules apply to your website depends on the individual case. This section is not legal advice; if in doubt, have it reviewed by an expert.
Common mistakes
- Light gray text: secondary text, captions or dates in
#999999are a classic. Even#767676meets AA on white. - Text on images: the background behind text on a photo changes constantly. Put a semi-transparent dark overlay or a gradient behind the text and check the lightest spot.
- Placeholder text: the text in empty form fields is often very pale. If it conveys information, it needs 4.5:1 – a visible label above the field is better.
- Links distinguished by color alone: if links in body text differ from the surrounding text only by color, people with color vision deficiencies won’t see them. Underline links, or at least ensure 3:1 against the surrounding text plus an additional cue on hover and focus.
- Hover and focus states: every state has to meet the values on its own. A button that gets lighter on hover can drop below the threshold. The focus indicator needs 3:1 against the background.
- Dark mode: check both color schemes separately. Pure white on a very dark background has plenty of contrast (
#FFFFFFon#121212: 18.73:1) but can feel harsh to some readers; a light gray is often more comfortable. Also watch out for accent colors chosen for a light background that are too dark in dark mode.
Fixing colors without ruining the design
Usually it is enough to shift a color’s lightness while keeping its hue and saturation. The color then remains recognizable as the same brand color. An example with orange on white:
| Color | Contrast on white | Use |
|---|---|---|
#FF6600 | 2.94:1 | surfaces and decoration only |
#C75000 | 4.59:1 | text, links, icons |
Both colors have the same hue; the second one is simply darker. You can keep using the bright variant for large surfaces and the darker one for text. The Color Contrast Checker (WCAG) suggests the closest color that reaches AA or AAA, and you can apply it directly.
Other options:
- Adjust the background instead of the foreground, for example make a button darker and keep the white text.
- Make the text larger or bolder – from 24 px, or 18.66 px bold, 3:1 is enough.
- Define colors as variables and set up separate, darker shades of your brand colors for text.
Plan for contrast from the start of a new project. If you already know your brand color, make sure the symbol and background of your favicon also stand out clearly from each other when you use the Favicon Generator – in a browser tab it is only a few pixels in size.
Outlook: APCA and WCAG 3
The WCAG 2 formula is simple but has weaknesses: for example, it is sometimes too strict with light text on a dark background and too lenient with dark text on mid-tones. The Advanced Perceptual Contrast Algorithm (APCA) is being discussed as an alternative. It takes font size and weight into account as well as polarity (light on dark or vice versa) and produces an “Lc” value.
WCAG 3, however, is a working draft, and according to the draft, the contrast method it will use has not yet been decided. The values of WCAG 2.x are the ones that currently apply. The Color Contrast Checker (WCAG) can additionally display the APCA value – use it as a guide, but always check against WCAG 2.2 as well.
Checklist
- Normal text at least 4.5:1, large text (from 24 px or 18.66 px bold) at least 3:1.
- For long texts, aim for 7:1 (AAA) where possible.
- Borders of UI components, focus indicators, icons and chart elements at least 3:1.
- Check every state: default, hover, focus, active – in both the light and the dark color scheme.
- Don’t rely on color alone to identify links.
- Back up text on images with an overlay or a gradient.
- Darken or lighten weak colors while keeping the hue.
Tools for this topic
- Color Contrast Checker (WCAG) Check color contrast against WCAG 2.2 – AA and AAA for text and UI components, with a live preview and color suggestions, right in your browser.
- Favicon Generator Create favicons from a logo or a letter – with favicon.ico, SVG, Apple and Android icons and HTML code as a ZIP.
More guides
- Special characters in database passwords Why @, :, / or # in a password break your DATABASE_URL and how to encode the password correctly – for Symfony, Laravel, Doctrine and Docker.
- Redirects for a website relaunch How to plan 301 redirects for a relaunch: collect old URLs, map targets, avoid chains and check the result.
- Which favicons does a website need? Which favicon files and sizes a website really needs today – favicon.ico, SVG, Apple touch icon and web manifest – including the HTML.
- Password-protect a directory (.htpasswd) Protect a directory or staging site with .htaccess and .htpasswd – for Apache and nginx, using secure hashing.
- Optimize images for the web Resize and compress images the right way: suitable sizes, WebP, AVIF or JPEG, quality, responsive images and lazy loading.
- UUID v4, v7 or ULID as a primary key? When UUIDs make sense as primary keys, why v7 and ULID suit databases better than v4 and how to store them.
- Using JWT securely Common security mistakes with JSON Web Tokens and how to avoid them: alg none, weak keys, missing checks and where to store tokens.