WCAG Contrast Ratios: How AA and AAA Are Calculated (2026)
A developer's guide to the WCAG contrast ratio formula, the 4.5:1 AA and 7:1 AAA thresholds, large-text exceptions, and how to check color contrast in code.
Tutorials, deep-dives, and privacy-first thinking about developer tools.
Showing 1–12 of 35 posts
A developer's guide to the WCAG contrast ratio formula, the 4.5:1 AA and 7:1 AAA thresholds, large-text exceptions, and how to check color contrast in code.
OKLCH in CSS gives you perceptually uniform color, wider P3 gamut, and predictable lightness. Here is the syntax, the math, and the fallbacks for 2026.
RGB to HEX is base-10 to base-16 on three bytes. Here's the exact math, the JavaScript one-liners, alpha channels, and the mistakes that trip people up.
In JavaScript str.length counts UTF-16 code units, so one emoji reports 2 and a family emoji reports 11. Here is how to count emoji characters correctly.
A HEX to RGB conversion is just base-16 to base-10 on three bytes. Here is the exact math, the shorthand rule, alpha, and the CSS syntax for 2026.
Splitting on spaces gives the wrong count for Chinese and Japanese. Here is how to count CJK words correctly with Intl.Segmenter and character counts.
Change one word and your diff lights up the whole line red and green. Here is why line-based diff does that, and how to switch to word-level.
The SMS 160-character limit comes from a 140-byte cap. One emoji or smart quote can drop it to 70 and double your bill — here's exactly why.
A UUID regex that only checks the 8-4-4-4-12 shape accepts garbage. Here's how to validate the version and variant nibbles the way RFC 9562 defines them.
Five regex mistakes that make a pattern match too much — greedy .*, unescaped dots, missing anchors, loose alternation, nested quantifiers — with the fix for each.
Line-level diff shines for code review; word-level diff catches the one edited word inside a long paragraph. Here's when to reach for each in 2026.
The LCS algorithm is how a diff tool finds the fewest insertions and deletions between two texts. Here is how longest common subsequence actually works.