Contrast ratio between two colors
Reference

Contrast ratio between two colors

Put in a text color and a background color and get the ratio, which thresholds it meets, and whether the text counts as large scale at the size you set it. The page is equally clear about what the number does not know.

Assumptions behind the numbers

  • The formula and the thresholds are from WCAG 2.1, Success Criteria 1.4.3 Contrast (Minimum) and 1.4.6 Contrast (Enhanced), published by the W3C Web Accessibility Initiative.
  • Relative luminance is calculated by linearising each sRGB channel and weighting them 0.2126 red, 0.7152 green and 0.0722 blue; the ratio is (lighter + 0.05) divided by (darker + 0.05), which runs from 1 to 21 (WCAG 2.1 SC 1.4.3).
  • Large scale text is at least 18 point, or 14 point bold (WCAG 2.1 SC 1.4.3). Below that the 4.5 to 1 threshold applies; at or above it, 3 to 1.
  • Ratios are not rounded up. WCAG's own explanation says 4.499 to 1 does not meet the 4.5 to 1 threshold, so this tool shows two decimals and fails anything under the line.
  • The ratio is calculated on two flat colors. WebAIM states that WCAG gives no guidance for gradients, semi-transparent colors or background images, and recommends testing the area of lowest contrast instead.
  • This is a screen standard. It says nothing about ink spreading on uncoated paper, glare on a laminated sign, the light in the room, a hairline typeface or how far away the reader is standing.