← Lessons

quiz vs the machine

Gold1350

Frontend

The Focus Visible Styling

Show a clear focus ring for keyboard users without cluttering the screen for people using a mouse.

4 min read · core · beat Gold to climb

Why a visible focus matters

Keyboard users need to see which element currently holds focus, just as a mouse user can see where the pointer is. That visible marker is the focus indicator, usually a ring around the active control. Removing it leaves keyboard users lost, so a clear indicator is a core requirement.

  • Never hide focus entirely by setting the outline to none with no replacement.
  • Keep enough contrast so the ring stands out against the background.
  • Make it thick enough to spot at a glance.

The focus visible refinement

A common worry is that focus rings appear on mouse clicks and look noisy. The focus visible behavior solves this by showing the ring only when the browser judges a keyboard or similar input was used.

  • Mouse clicks usually suppress the ring, reducing visual noise.
  • Keyboard navigation shows the ring so users keep their place.
  • A safe fallback still styles plain focus for older engines.

Building a good indicator

  • Replace any removed outline with your own visible style.
  • Test the ring on light and dark backgrounds and on every control.
  • Avoid relying on color alone so the change is clear without it.

Key idea

Always provide a clear focus indicator, and use focus visible so the ring appears for keyboard users while staying quiet for mouse clicks.

Check yourself

Answer to earn rating on the learn ladder.

1. What is the danger of setting outline to none with no replacement?

2. What does focus visible styling achieve?