Example 1 — Keyboard Focus Ring
The ring appears when the button receives focus and the browser's focus-visible heuristic applies.
<style>
button:focus-visible {
outline: 3px solid #2563eb;
outline-offset: 3px;
}
</style>
<button type="button">Tab to me</button> How It Works
- The browser evaluates
button:focus-visibleagainst the document. - Only elements satisfying that selector receive the declarations.
- The rule changes the visible state without changing the HTML structure.
- Open the editor to test the selector with different markup.

