TR

Home / Guides / What Is Color Contrast Ratio? A Step-by-Step WCAG AA and AAA Calculation with Example Colors

What Is Color Contrast Ratio? A Step-by-Step WCAG AA and AAA Calculation with Example Colors

Updated: November 6, 2026 · AracMerkezi

▶ Open Color Contrast Checker (WCAG)

The contrast ratio between text and background color is one of the most important factors in how comfortably a piece of writing can be read. It matters for users with low vision, but also for anyone using a phone in the sun. In this guide we do not stop at giving the thresholds; we show how the ratio is calculated by working through one gray step by step, put the calculated results for common color pairs in a table, and explain why borderline values need care.

What is contrast ratio?

WCAG (the Web Content Accessibility Guidelines) defines the ratio between the relative luminances of two colors as a value between 1:1 and 21:1. Identical colors give 1:1, and black on white gives 21:1. As the ratio increases, readability increases.

Required ratios

LevelNormal textLarge text
AA4.5:13:1
AAA7:14.5:1

Large text is regular text of about 24 px (18 pt) and above, or bold text of about 18.66 px (14 pt) and above. In practice, the target for most sites should be level AA. For interface parts other than text as well (button borders, form field outlines, icons), a ratio of at least 3:1 against the background is expected. For the rem equivalents of pixel units, see the guide to px, rem and em.

How is the ratio calculated step by step?

The calculation has two stages: first the relative luminance (L) of each color, then the ratio of the two luminances.

  1. Divide each channel (R, G, B) by 255.
  2. If the value is 0.03928 or less, divide it by 12.92; if it is larger, raise ((c + 0.055) / 1.055) to the power of 2.4.
  3. Luminance: L = 0.2126 × R + 0.7152 × G + 0.0722 × B.
  4. Ratio: (L lighter + 0.05) / (L darker + 0.05).

Example 1: #767676 gray on a white background

  1. All three channels are 118; 118 / 255 = 0.4627.
  2. ((0.4627 + 0.055) / 1.055)²·⁴ ≈ 0.1812. Because the three channels are equal, the weights add up to 1 and L ≈ 0.1812.
  3. The luminance of white is 1.
  4. Ratio = (1 + 0.05) / (0.1812 + 0.05) = 1.05 / 0.2312 ≈ 4.54:1.

The result is just above 4.5; so #767676 is the lightest gray that passes AA on a white background. #777777, one step lighter, comes out at 4.478 and fails for normal text. This small-looking difference shows the danger of rounding to "about 4.5": the comparison is made with the unrounded value.

Example 2: #999999 gray on a white background

Using 153 instead of 118, the channel becomes 0.6, the linear value is ≈ 0.3185, and the ratio comes out as 1.05 / 0.3685 ≈ 2.85:1. This cannot pass even 3, the large-text threshold. Although light gray text looks stylish in a design, it often has insufficient contrast; this is one of the most common accessibility mistakes.

Example 3: Button and text colors

The ratios below were calculated with the WCAG formula and compared with the formula used by the checking tool on the site.

Text / BackgroundRatioAA normalAA largeAAA normal
Black / White21.00:1PassPassPass
#595959 / White7.01:1PassPassPass
#6B7280 / White4.83:1PassPassFail
#767676 / White4.54:1PassPassFail
#777777 / White4.48:1FailPassFail
White / #2563EB5.17:1PassPassFail
White / #3B82F63.68:1FailPassFail
#FF0000 / White4.00:1FailPassFail
#999999 / White2.85:1FailFailFail

Takeaway: on a button with white text, a #2563EB background passes AA comfortably, while the slightly lighter #3B82F6 is enough only for large text. Pure red (#FF0000) on white is very close to 4 (3.998) but cannot pass 4.5.

Example 4: The same gray on a different background

Contrast is not a property of a single color but of a pair. The gray #6B7280 gives 4.83:1 on a white background and passes AA. The same gray on a dark background (#111827) gives only 3.67:1 and fails for normal text. If you use gray text in a dark theme, you need a lighter shade: #9CA3AF gives 6.99:1 on the same #111827 background; it passes AA and falls only just short of AAA. A light gray #E5E7EB passes comfortably at 14.33:1. That is why sites with theme switching need to measure the colors separately for each theme.

How can it be improved?

  1. Darken the text color or lighten the background.
  2. Use higher contrast for thin and small text.
  3. Do not use color alone to carry information; in cases such as errors, add an icon or text too.
  4. When putting text over an image, add a semi-transparent layer.
  5. Test button and link states (hover, focus) as well.
  6. If you use a dark theme, check the ratios separately in both themes.

Common mistakes

  1. Judging the ratio "enough" by eye without measuring.
  2. Treating a value like 4.48 as 4.5 and counting it as a pass.
  3. Applying the large-text threshold to all headings; if a heading is not large and bold enough, the normal-text rule applies.
  4. Skipping not only text but also borders and icons.
  5. Not measuring the worst point for text over an image or gradient.
  6. Not testing hover and focus states.

Short glossary

When to use it and its limits

Contrast ratio is a readability measure; it does not guarantee all accessibility. Font, size, line spacing and the user's screen settings matter too. Logos and purely decorative text may be exempt from the thresholds; still, confirm this with your project's or organization's rules. Where legal compliance is required, check the applicable standard and its version in the relevant sources. A practical method: list the colors you will use in a table, measure each pair, replace the ones that fail with a darker or lighter shade, and then check the page again by eye.

The Color Contrast Checker tool calculates the numbers for you and also shows a pass or fail result for the four levels. For choosing colors, take a look at the Web Color Palette Guide, and for the RGB equivalent of HEX codes, the HEX and RGB guide.

Frequently asked questions

What contrast ratio is required for AA?

At least 4.5:1 for normal text and 3:1 for large text.

How is large text defined?

Regular text of about 24 px and above, or bold text of 18.66 px and above.

What is the contrast of black on white?

21:1, the highest possible value.

Tools mentioned in this guide

More guides

This article is for general information only and is not legal, financial or medical advice. We are not an official institution.