Urgent.News

What's breaking now, across hundreds of outlets.

Tech

WCAG 2.2 AA & AAA Color Contrast Cheat Sheet for Devs

Nothing fails a Lighthouse accessibility audit—or frustrates real users squinting at their phone in daylight—faster than sleek, low-contrast grey text ( #9ca3af ) sitting on a white or translucent glassmorphic card. Beyond user experience, WCAG 2.2 Level AA contrast compliance is now a legal requirement across the EU European Accessibility Act (EAA) , US ADA / Section 508 , and enterprise SaaS…

WCAG 2.2 Level AA and AAA color contrast guidelines are now legally required under the EU's European Accessibility Act (EAA), US ADA / Section 508, and enterprise SaaS procurement checklists. Failure to meet these contrast requirements can cause Lighthouse accessibility audits to fail and frustrate real users viewing content in bright daylight.

The WCAG 2.2 cheat sheet provides the exact contrast thresholds for various element types and font sizes. Normal body text (18pt or 14pt bold) must have a contrast ratio of 4.5:1 to 7.0:1, while large text (18pt or 14pt bold) needs a minimum of 3.0:1 to 4.5:1. Hero headlines, input borders, focus rings, and non-text UI components have different requirements.

It's important to note the conversion between points (pt) and pixels (px), as 1pt equals 1.333px. Therefore, 14pt bold should be a minimum of 18.67px to meet the Large Text threshold. Many developers make the mistake of using 14px bold instead, which still requires meeting the full 4.5:1 ratio.

The cheat sheet also offers pre-built accessible color pairs for both light and dark themes, ensuring that buttons, text, and other UI elements meet the contrast requirements. These color tokens have been battle-tested and verified to pass the 4.5:1 minimum for normal text and 3.0:1 for large text.

In addition to the main text contrast, it's crucial to test focus states and hover states, as these can sometimes fall below the minimum contrast ratio. Always verify that keyboard focus outlines meet the 3.0:1 requirement against adjacent backgrounds.

The WCAG contrast formula involves converting RGB values to relative luminance (L) and then calculating the ratio between the lighter and darker colors. However, for practical purposes, developers can use the provided color tokens and checkers to ensure compliance without needing to perform manual calculations.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

AI and GDPR: what data to entrust to an AI tool?

You can have personal data processed by an AI under four conditions: knowing what the processing is for, sending only what the model needs to the model, having a contract with the provider that states…

BitBox02 USB HID request handling: firmware size checks belong on the trust boundary

BitBox02 USB HID request handling: firmware size checks belong on the trust boundary BitBox02 firmware before 9.26.2 and bootloader before 1.2.0 contain an out-of-bounds write in the USB HID request…

  • Firmware size checks in BitBox02 USB HID request handling are on trust boundary.
  • CVE-2026-140033 allows out-of-bounds write in USB HID request handler.
  • Update to firmware 9.26.2 or later and bootloader 1.2.0 to mitigate risk.

More from Tuesday, 1 December 2026 →