HTML & CSS · Middle · Question 38 of 75
Why is :focus-visible better than :focus for styling the focus outline?
- ✓Correct answer: It shows the outline during keyboard navigation and usually hides it on mouse clicks
- 2It works only on touch devices that have no mouse pointer
- 3It's a legacy variant of
:focuskept for old browsers
Explanation
Designers used to ask to remove the "ugly" ring after a click, and outline: none broke keyboard accessibility. :focus-visible uses a browser heuristic: during keyboard navigation the outline is visible, on a mouse click on a button it usually isn't. Never remove focus indication entirely.