THE GITHTML FIELD GUIDE

Restore visible focus without removing browser defaults blindly

Keep a visible focus indicator on document links and controls. Use focus-visible for a deliberate keyboard-oriented treatment where appropriate, while preserving a usable fallback. Do not remove outlines globally to improve a screenshot; readers navigating without a pointer need to know which element will respond before they activate it.

Understand the access barrier

A link can have sufficient text contrast yet become impossible to locate when focused. Small color changes are particularly easy to miss among dense paragraphs. The indicator should remain distinguishable against the local background.

Use a deliberate document pattern

Add a clear outline with enough separation from the text and inspect clipping containers. A strong outline can still disappear if an ancestor hides overflow. Test links inside callouts and dark panels, not only ordinary white-background prose.

  1. Preserve browser focus styling until an equally usable replacement is verified.
  2. Check the indicator against every background used around interactive content.
  3. Inspect clipping and overlap that can hide an otherwise correct outline.
text
a:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }

Check the actual reading experience

Move focus through the page without clicking. At each stop, identify the target before pressing Enter.

Check focus across a real reading route

Start with a report containing body links, a dark warning panel, a contents list, and a horizontal table region. Tab through the actual sequence and identify the focused target before activating it. An outline based on currentColor may work on ordinary prose but become weak against a differently colored panel. Check each local background rather than choosing a color solely from the page’s main palette.

Clipping is a separate failure from contrast. A link inside a rounded container with hidden overflow can have a strong outline that is cut off at the container edge. An outline offset may also collide with adjacent text in tightly packed navigation. Adjust the local spacing or clipping behavior while preserving the visual design’s purpose. Do not solve a clipped ring by removing the indicator; the keyboard user still needs to know where focus is.

Focus-visible lets the browser use its interaction heuristics to decide when a focus indicator is needed; it is not simply a universal keyboard detector. Preserve default focus behavior unless your replacement is proven usable in supported environments. Check backward navigation with Shift+Tab, browser zoom, and forced-colors or high-contrast settings where relevant. Avoid using a color change alone when a clear outline or other shape can make the state easier to locate. If a sticky toolbar covers the focused link, repair the visibility and scrolling behavior too. A focus treatment succeeds when the reader can locate and identify every interactive stop, not when one isolated component looks polished in a static screenshot.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All accessible documentation guides →

Read as MarkdownAll guides

Restore visible focus without removing browser defaults blindly · gitHtml