Code Fix Guide

How to Fix Missing or Removed Focus Indicators

Many websites remove the default browser focus outline with 'outline: none' for aesthetic reasons, but this makes the site completely unusable for keyboard users. They can't see which element is currently focused. The fix isn't to keep the ugly default — it's to design a better focus indicator.

Common Errors and How to Fix Them

Globally removing focus outlines
Problem
*:focus {
  outline: none;
}
Fix
/* Remove only for mouse users, keep for keyboard */
*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
  border-radius: 2px;
}
Removing focus from links
Problem
a:focus {
  outline: 0;
  text-decoration: none;
}
Fix
a:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

a:focus:not(:focus-visible) {
  outline: none;
}
Removing all focus indicators from buttons
Problem
button:focus {
  outline: none;
  box-shadow: none;
}
Fix
button:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

Why This Matters

Invisible focus indicators violate WCAG 2.4.7 (Focus Visible). The :focus-visible CSS pseudo-class is the modern solution — it shows focus styles only for keyboard navigation, not mouse clicks, satisfying both design and accessibility requirements.

Find All Your Accessibility Issues Automatically

ADA CodeFix scans your website for WCAG 2.1 AA violations and generates AI-powered code fixes — not vague descriptions, actual code you can copy-paste.

Scan Your Site Free
No credit card required AI-generated code fixes