pseudo-class
:focus — CSS reference
Matches the currently focused element. Preserve a visible focus indicator for keyboard navigation.
Formal Syntax & Structure
css syntaxcss
:focusWorking Example
Example Snippetcss
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Selector lab</title><style>:where(.sample) { color: rgb(32, 32, 32); }button:focus { color: rgb(0, 96, 80); }</style></head><body><button id="a" class="sample">A</button><button id="b" class="sample">B</button></body></html>