:focus-visible

A CSS pseudo-class that matches a focused element only when the browser thinks a focus indicator is needed, typically for keyboard use.

In more detail

Styling :focus-visible instead of :focus shows a clear focus ring to keyboard users without drawing rings after every mouse click. Rings must meet contrast requirements and stay visible in forced colors mode.

Related terms

Taught in

References