Focus State
The visible indication of which element will receive keyboard input.
See it on the 3D treeGoing deeper
Usually an outline or ring, it follows keyboard users as they Tab through links, fields and buttons. It must stand out against every background it appears on. In CSS, the focus-visible selector lets browsers show the ring when it is useful, such as for keyboard use, without showing it on every mouse click.
Why it matters
Without it, keyboard users cannot tell where they are or what pressing Enter will do.
In practice
You specify a two-pixel outline with a small offset that remains visible on both the white page and the dark header.
Common mistake
Removing the browser's default outline for looks and providing nothing in its place.
Connected terms
- Hover StateHover follows the pointer; focus marks where keyboard input will go, and both can show at once.
- Focus OrderThe ring should move through the page in a logical sequence.
- Keyboard NavigationKeyboard navigation is only usable when the current position is visible.
- VariantInteractive variants need a visible focus appearance for keyboard users.
- WCAGWCAG requires keyboard focus to be visible.