Understanding WCAG Color Contrast

Featured graphic for “Understanding WCAG Color Contrast” showing color swatches and HEX codes

Text that is hard to read loses visitors. For people with low vision, color blindness or a phone screen in bright sunlight, poor contrast can make content unusable. The Web Content Accessibility Guidelines (WCAG) set clear, measurable contrast targets. Here is what they mean and how to meet them.

What Is a Contrast Ratio?

A contrast ratio compares the relative brightness (luminance) of two colors. It ranges from 1:1 (identical colors) to 21:1 (black on white).

#111827 on white — about 17.7:1 (passes AAA)
#6C5CE7 on white — about 4.85:1 (passes AA)
#94A3B8 on white — about 2.6:1 (fails for text)

WCAG 2 Requirements

ContentLevel AALevel AAA
Normal text4.5:17:1
Large text (24px+, or ~18.66px+ bold)3:14.5:1
UI components and meaningful graphics3:1—

Most websites aim for AA. Logos and purely decorative elements are exempt.

How the Ratio Is Calculated

  1. Convert each RGB channel to a 0–1 value and linearize it (values ≤ 0.03928 are divided by 12.92; others use ((v + 0.055) / 1.055)^2.4).
  2. Compute relative luminance: L = 0.2126 R + 0.7152 G + 0.0722 B. Green counts most because our eyes are most sensitive to it.
  3. Ratio = (L1 + 0.05) / (L2 + 0.05), with L1 the lighter color.

You don’t need to do this by hand — our Color Contrast Checker does it instantly and rounds down so borderline results are never falsely reported as passing.

How to Fix Failing Colors

  • Darken the text or lighten the background in small steps. In HSL, change only lightness to keep the same hue.
  • Make text larger and bolder so the 3:1 large-text threshold applies (only when appropriate).
  • Use brand colors for large elements and darker variants for body text and links.
  • Add overlays behind text on images, such as a semi-transparent dark gradient.

Don’t Rely on Color Alone

WCAG also requires that color is not the only way information is shown. Mark form errors with text and icons, underline links in paragraphs or make them clearly distinguishable, and label chart lines directly.

Quick Checklist

  • Body text ≥ 4.5:1
  • Headings and large text ≥ 3:1
  • Button text ≥ 4.5:1 against the button color
  • Input borders and icons ≥ 3:1 against the background
  • Placeholder text treated as real text if it conveys information

Why Color Contrast Matters

Good contrast is not just a design preference; it decides whether people can read your content at all. Hundreds of millions of people worldwide live with some form of visual impairment, and many more experience temporary difficulties: reading a phone in bright sunlight, using an old laptop with a dim screen, or simply having tired eyes at the end of the day. Low-contrast text forces all of these users to strain, slows them down and can make them leave your website.

Color vision deficiency is also common. Roughly one in twelve men and one in two hundred women have trouble distinguishing certain colors, most often reds and greens. Contrast based on lightness, which is what WCAG measures, helps these users because it does not depend on seeing hue correctly.

There are also business and legal reasons. Many countries require public sector websites, and increasingly private businesses, to meet accessibility standards that reference WCAG. Better contrast also improves usability for everyone, which can increase time on page, conversions and trust.

How the Contrast Ratio Is Calculated

WCAG defines contrast as a ratio between the relative luminance of two colors. Relative luminance describes how bright a color appears to the human eye, on a scale from 0 for black to 1 for white. The formula is:

contrast ratio = (L1 + 0.05) / (L2 + 0.05)

Here L1 is the luminance of the lighter color and L2 is the luminance of the darker color. The 0.05 values account for typical viewing conditions and prevent division by zero. The result ranges from 1:1 (no contrast, the same color) to 21:1 (black on white).

Calculating relative luminance

To get luminance, each RGB channel is first converted to a value between 0 and 1 and then linearized to remove the gamma curve used by screens. Finally, the channels are weighted according to how sensitive our eyes are to each color:

L = 0.2126 × R + 0.7152 × G + 0.0722 × B

Notice that green contributes far more than blue. This is why a pure blue #0000FF looks quite dark and has strong contrast on white, while a pure yellow #FFFF00 looks very bright and has almost no contrast on white.

Example calculations

  • #000000 on #FFFFFF: 21:1, the maximum possible.
  • #595959 on #FFFFFF: about 7:1, passes AAA for normal text.
  • #767676 on #FFFFFF: about 4.5:1, the lightest gray that passes AA for normal text on white.
  • #949494 on #FFFFFF: about 3:1, acceptable only for large text and UI components.
  • #FFFF00 on #FFFFFF: about 1.07:1, effectively invisible.

What Counts as Large Text

WCAG allows lower contrast for large text because bigger letters are easier to read. Text is considered large when it is at least 18 point (about 24 CSS pixels) in regular weight, or at least 14 point (about 18.66 CSS pixels) in bold. Most body text, captions, labels and navigation links are smaller than this and must meet the stricter 4.5:1 requirement.

Font choice matters too. Thin or light font weights look lower in contrast than their ratio suggests, because there is less ink on the screen. If you use a light typeface, aim for a higher ratio than the minimum.

Non-Text Contrast

WCAG 2.1 added a requirement for non-text elements. Important user interface components and meaningful graphics need a contrast ratio of at least 3:1 against adjacent colors. This includes:

  • Borders of input fields, checkboxes and radio buttons.
  • Icons that communicate meaning without accompanying text.
  • Focus indicators that show which element is selected when navigating by keyboard.
  • Lines and segments in charts and graphs.
  • Toggle switches, sliders and progress bars.

A very common failure is a light gray input border such as #E5E7EB on a white page, which has only about 1.2:1 contrast. Changing it to #9CA3AF or darker makes form fields much easier to find.

Decorative elements, disabled controls and logos are exempt from contrast requirements. However, disabled buttons should still be recognizable as buttons, even if they are not meant to be used.

Common Contrast Failures and How to Fix Them

Light gray body text

Minimal designs often use pale gray text such as #AAAAAA on white. It looks elegant in a design file but has only about 2.3:1 contrast. Darken it to #595959 or #4B5563 to pass comfortably while still feeling softer than black.

Placeholder text in forms

Placeholders are usually styled very light. If the placeholder contains important instructions, it must meet 4.5:1. A better approach is to place instructions in a visible label above the field.

White text on bright colors

White text on yellow, light green, orange or light blue buttons often fails. For example, white on #F59E0B amber is only about 2.1:1. Use dark text on bright buttons, or darken the button color until white text passes.

Text on images

Text placed directly over photos may have good contrast in one area and terrible contrast in another. Add a semi-transparent dark overlay, a solid background behind the text or a subtle text shadow, and check contrast against the lightest part of the image behind the words.

If links are identified only by color, the link color must have at least 3:1 contrast with the surrounding text, in addition to 4.5:1 against the background. The simpler solution is to underline links so they do not rely on color alone.

Hover and focus states

Designers often check the default state and forget the others. A button that passes normally might fail when hovered if the background becomes lighter. Test every state, including focus outlines for keyboard users.

Accessible Color Combinations You Can Use

These pairs meet at least AA for normal text:

  • #1F2937 text on #FFFFFF background — about 14.7:1
  • #FFFFFF text on #1D4ED8 background — about 6.7:1
  • #FFFFFF text on #047857 background — about 5.5:1
  • #FFFFFF text on #B91C1C background — about 6.5:1
  • #111827 text on #FDE68A background — about 14:1
  • #0F172A text on #E0F2FE background — about 16:1
  • #F8FAFC text on #0F172A background — about 17:1

Always confirm the exact values in a contrast checker, since small changes in a color can move the ratio above or below the limit.

Contrast in Dark Mode

Dark themes need contrast checks just as much as light themes. Pure white text on pure black reaches 21:1, but such extreme contrast can cause glare and a halo effect for some readers, especially people with astigmatism. Many dark themes use light gray text such as #E5E7EB on a dark blue-gray like #111827, which still exceeds 14:1 while feeling more comfortable.

Be careful with colored text in dark mode. Brand colors designed for light backgrounds are often too dark to read on dark surfaces. A blue like #1D4ED8 has strong contrast on white but weak contrast on #111827. Use a lighter variation such as #60A5FA for dark mode links and accents.

WCAG 2 vs the Upcoming APCA Model

The current WCAG 2 contrast formula has been widely used for many years, but it is not perfect. It sometimes rates dark colors on black as acceptable when they are hard to read, and it treats light-on-dark and dark-on-light combinations the same, even though our eyes perceive them differently.

A newer method called the Advanced Perceptual Contrast Algorithm (APCA) is being researched for future accessibility guidelines. APCA considers font size, font weight and whether the text is lighter or darker than its background. It produces a score called Lc rather than a ratio. For now, WCAG 2 remains the standard referenced by laws and audits, so you should continue to meet its requirements while keeping an eye on how future guidelines develop.

How to Test Contrast in Your Workflow

  1. During design: check text and background pairs as soon as you create a palette. Fixing colors early is much easier than later.
  2. In design tools: many tools offer plugins that check contrast for selected layers.
  3. In the browser: developer tools show the contrast ratio when you inspect a text element and click its color swatch.
  4. With automated audits: accessibility testing tools can scan entire pages and list contrast failures.
  5. With real users: automated tests cannot catch everything, such as text over complex images. Manual reviews and user testing complete the picture.

Building an Accessible Color Palette from the Start

Rather than testing colors after a design is finished, it is far more efficient to build contrast into your palette from day one. A simple approach is to create a scale of lightness steps for each brand color, from very light to very dark, and record which steps pass on white and which pass on your darkest background.

For example, if your brand blue has ten steps from 50 to 900, you might find that steps 600 and above pass 4.5:1 on white, while steps 100 and below pass on your dark background. Document these rules: “Use blue 600 or darker for text on light backgrounds; use blue 200 or lighter for text on dark backgrounds.” Designers and developers can then choose colors confidently without testing every combination.

It also helps to define specific color roles. A “text-primary” color, a “text-secondary” color, a “border” color and a “focus” color, each tested against every background they will appear on, prevent accidental failures when new pages are created.

Contrast for Charts, Maps and Infographics

Data visualizations are often overlooked in accessibility audits. Lines, bars and map regions need enough contrast against the background and against each other so that people can tell them apart. Aim for at least 3:1 between each data color and the background, and avoid placing two similar-lightness colors next to each other.

Because some users cannot rely on hue, add patterns, direct labels or different marker shapes to separate data series. A line chart with solid, dashed and dotted lines, or a bar chart with values printed on each bar, remains readable even in grayscale.

Accessibility Contrast Checklist

  • All body text meets at least 4.5:1 against its background.
  • Large headings meet at least 3:1, and preferably 4.5:1.
  • Form field borders, icons and focus indicators meet at least 3:1.
  • Links are underlined or clearly different from body text.
  • Hover, focus, active and disabled states have been tested.
  • Text over images uses an overlay or solid background.
  • Dark mode colors have been tested separately from light mode.
  • Charts use patterns or labels in addition to color.
  • Information is never communicated by color alone.

Working through this checklist before every launch helps ensure your website is readable, usable and welcoming for every visitor, regardless of their eyesight, device or environment.

Understanding the Three Conformance Levels

WCAG organizes its success criteria into three levels. Level A covers the most basic requirements; failing them makes content impossible for some people to use. Level AA is the level most laws, public bodies and companies aim for, and it includes the 4.5:1 and 3:1 contrast rules. Level AAA is the highest level, requiring 7:1 for normal text and 4.5:1 for large text.

Meeting AAA across an entire website is often difficult, especially with strong brand colors, so it is usually not required. However, it is an excellent target for long-form reading content such as articles, documentation and legal pages, where users spend a lot of time reading. If your body text already meets AAA, readers with low vision will find your content noticeably easier to use.

Myths About Color Contrast

“High contrast looks ugly.” Accessible designs can be beautiful. Many award-winning websites use soft backgrounds with deep, readable text and still feel elegant.

“Black on white is always best.” Maximum contrast is fine, but very dark gray on off-white is often more comfortable for long reading while still exceeding AAA.

“Contrast only matters for people with disabilities.” Everyone benefits from readable text, especially on mobile devices outdoors.

Frequently Asked Questions

Many accessibility laws and policies reference WCAG, depending on your country and sector. Meeting WCAG AA is a widely accepted baseline, but consult a qualified professional for legal compliance.

Do logos need to meet contrast requirements?

No. Text that is part of a logo or brand name is exempt.

Why does #777777 on white fail AA?

Its ratio is about 4.48:1, just below 4.5:1. Rounding down prevents borderline colors from being treated as passing.

Written by the Mage Color Picker Team

We build free online color tools and write practical guides on color theory, color codes and accessible design for designers and developers.

Scroll to Top