Urgent.News

What's breaking now, across thousands of outlets.

Tech

How to Check Color Contrast for Accessibility (WCAG Explained)

Low-contrast text is one of the most common accessibility failures on the web, and one of the easiest to fix. It affects people with low vision and color-vision differences, but also anyone reading a phone screen in bright sunlight. The Web Content Accessibility Guidelines (WCAG) turn "readable enough" into a number you can test. What contrast ratio means Contrast ratio compares the relative…

Low-contrast text presents a major accessibility issue on the internet, yet fixing it is simple. It impacts users with low vision, color-vision differences, and those reading on bright screens outdoors. The Web Content Accessibility Guidelines (WCAG) quantify contrast through a ratio. Contrast ratio measures relative luminance between two colors, scaling from 1:1 (identical hues) to 21:1 (black on white).

Calculating luminance involves linearizing sRGB values and applying weightings favoring green while minimizing blue impact. WCAG outlines contrast thresholds: Level AA for normal text requires a minimum 4.5:1 ratio, while large text (18pt/24px or bigger, or 14pt/18.66px bold) needs at least 3:1. For Level AAA compliance, normal text should meet a 7:1 ratio, and large text should meet 4.5:1.

Non-text contrast also applies to UI elements such as input borders, icons, and focus indicators, necessitating a minimum 3:1 against adjacent colors. Teams typically aim for AA compliance. Decorative text, logo elements, and disabled components are exempt from these requirements.

A frequent error is using light gray text on white backgrounds, which often yields a contrast ratio around 2:1. Text placed over photos or gradients can also fail, as contrast varies along the line. Moreover, checking only the default state while ignoring hover, focus, and visited link colors is another common oversight. Also, relying on color alone to convey information—like red-green status dots without labels or icons—is problematic.

To rectify failing color pairs, maintain hue while adjusting lightness by minor increments. Reassess contrast after each modification until the target ratio is achieved. For text superimposed on images, insert a solid or semi-transparent overlay behind the text, rather than relying on the photo's inherent contrast.

Define accessible color tokens within your design system, ensuring every component inherits these settings. While passing the contrast ratio is crucial, it is not the sole criterion. Testing with actual users, utilizing color-blindness simulators, and avoiding reliance on color as the sole signal are equally important. Additionally, dark modes require separate contrast assessments, as pure white on pure black can cause glare for some readers, prompting many designs to opt for off-white on very dark gray instead.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Unix Timestamps Explained: Seconds, Milliseconds, and Time Zones

A Unix timestamp (also called epoch time or POSIX time) is the number of seconds that have passed since 00:00:00 UTC on 1 January 1970, a moment known as the Unix epoch.

  • Unix timestamp represents seconds since 1970 epoch
  • Seconds vs milliseconds differentiated by number length
  • Store timestamps in UTC to avoid Year 2038 problem

How to Make a WiFi QR Code (So Guests Never Ask for the Password)

Reading a long, random WiFi password aloud to every guest gets old quickly. A WiFi QR code solves it: point a phone camera at the code and the phone offers to join the network.

  • WiFi QR codes simplify connecting to networks without sharing passwords.
  • iPhones (iOS 11+) and many Android phones can scan these codes.
  • Use a browser-based generator, test, and print at readable size near router.

How Strong Should a Password Be? Length vs. Complexity

Password strength is really a question of how many guesses an attacker would need. Every extra character multiplies that number, which is why length matters far more than swapping an a for an @.

  • Length of password exponentially increases possible guesses for attacker
  • Entropy measures password unpredictability in bits, doubles with each bit
  • Passphrases made of random words offer strong security and memorability

Base64 Is Not Encryption (And Other Common Misconceptions)

Base64 shows up everywhere: emails, data URLs, HTTP headers, JWTs. Because the output looks scrambled, it is often mistaken for encryption. It isn't.

  • Base64 is an encoding method, not encryption
  • It converts binary data to text format, reversible by anyone
  • Used for text-only channels, not providing secrecy

Regex Cheatsheet for Beginners (With Copy-Paste Examples)

Regular expressions look cryptic at first, but a small set of building blocks covers most real-world tasks: validating input, searching logs, and doing bulk find-and-replace.

  • Dot character . matches any character except newline
  • Character classes like [abc] match specific options
  • Quantifiers specify occurrence counts like , +, ?

More from Saturday 26 September →