{
  "id": 7621370,
  "title": "Color Contrast Ratios: The Reference Tables and Edge Cases Every Frontend Engineer Should Memorize",
  "url": "https://urgent.news/2026/09/15/color-contrast-ratios-the-reference-tables-and-edge-cases-every",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-15T20:02:54.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/lizely/color-contrast-ratios-the-reference-tables-and-edge-cases-every-frontend-engineer-should-memorize-c57"
  },
  "original_language": "en",
  "account": "Contrast ratios are a critical aspect of web accessibility that frontend engineers should be familiar with. The article titled \"Color Contrast Ratios: The Reference Tables and Edge Cases Every Frontend Engineer Should Memorize\" provides a detailed guide on how to calculate contrast ratios and the common pitfalls to avoid. The two primary factors determining contrast ratios are the relative luminance of the foreground (text or icon) and background colors. Relative luminance is calculated through a piecewise function based on the sRGB color space, which involves linearizing the sRGB channel values and applying specific weights to the resulting channels.\n\nThe formula for contrast ratio is ((L1 + 0.05) / (L2 + 0.05)), where L1 is the lighter luminance value and L2 is the darker one. The result ranges from a minimum of 1:1 (identical colors) to a maximum of 21:1 (black on white). Before diving into the specifics, it's essential to understand two key points: the 0.05 offset in the formula prevents division by zero and keeps ratios finite, and luminance is channel-weighted, meaning that two colors with the same hex brightness can yield vastly different ratios depending on their hue distribution.\n\nThe article then presents a reference table outlining the minimum contrast ratios for various element types per the WCAG (Web Content Accessibility Guidelines) standards. This table classifies elements into non-text, large text, and UI components, each with its respective minimum contrast ratios. For example, body text requires a minimum contrast ratio of 4.5:1, while large text only needs a ratio of 3:1.\n\nThe article also highlights several edge cases that can cause contrast ratio issues to slip through the cracks. Translucent layers, focus rings, disabled states, hover and active swaps, and gradient backgrounds are some of the common scenarios where engineers need to adjust their approach to ensure proper contrast ratios are maintained. For instance, translucent layers require sampling the actual pixel value at the text's position to determine the effective color for contrast calculation.\n\nTo streamline the process of maintaining contrast ratios across a large codebase, the article outlines a token-level audit routine. This routine involves exporting design tokens as JSON, computing contrast ratios for each (foreground, background) pair, and comparing them against the WCAG guidelines. The routine helps catch any failures early in the development process, ensuring that the codebase remains accessible and compliant with the necessary standards.",
  "summary": "When a design reviewer rejects a button because \"the text doesn't have enough contrast,\" the conversation usually stalls at a vague sense that something looks washed out. The actual rule behind that judgment is a deterministic formula, a small set of thresholds, and a handful of traps that make naive implementations fail at audit time. This article is a working reference: the numbers, the…",
  "key_points": [
    "Contrast ratios measure text/background color readability.",
    "Formula: (L1 + 0.05) / (L2 + 0.05) for WCAG compliance.",
    "Edge cases include translucent layers and gradient backgrounds."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}