Urgent.News

What's breaking now, across thousands of outlets.

Tech

The outline: none Debate Has Been Over Since 2020

A design review flags it every time: a button gets clicked, and a chunky blue ring slaps itself around the edge for half a second. "Can we remove that? It looks broken." The engineer knows the one-line fix. * :focus { outline : none ; } Ship it. The review passes. The button looks clean in every screenshot, in every browser, on every click. Three weeks later an accessibility audit comes back with…

The issue of invisible focus outlines on buttons has been a long-standing problem in web design. A design review once flagged a chunky blue ring that appeared around a button each time it was clicked, deeming it "broken". After a few weeks, an accessibility audit revealed that keyboard users couldn't determine which element had focus, rendering the clean-looking button indistinguishable from other pixels on the screen.

This lack of an outline was a WCAG 2.4.7 success criterion failure. The instinct was to either remove the ring or make it conditional for keyboard users. However, the correct solution was to use the :focus-visible pseudo-class, which exposes to CSS whether a focus event originated from a keyboard or a pointer. This allowed for a clean and accessible button design that works in every modern browser.

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

More from Saturday 29 August →