Give links, buttons and form fields a strong, visible outline when they're reached with the keyboard, without showing it on mouse clicks.
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
outline: 3px solid #6F58CA;
outline-offset: 2px;
border-radius: 2px;
}
/* Some themes remove outlines completely. Put them back for keyboard users. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus:not(:focus-visible) {
outline: none;
}
People who use a keyboard, switch device or screen magnifier need to see where they are on the page. Many themes hide the focus outline because it looks untidy after mouse clicks. This CSS brings it back only for keyboard focus.
:focus-visible matches when the browser decides focus should be shown, which is almost always keyboard navigation and not mouse clicks. The rule gives those elements a 3 px outline with a little space around it.
Wrapping the selectors in :where() keeps their specificity at zero, so your theme’s own focus styles still win if it has good ones.
#6F58CA to suit.outline: none !important. Add !important to the first rule.Load a page and press Tab repeatedly. Each link and button should get a clear purple outline. Clicking with the mouse shouldn’t show it.