HTML & CSS · Middle · Question 38 of 75

Why is :focus-visible better than :focus for styling the focus outline?

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.

Further reading

Problem with a question

HTML & CSS · Middle · question 38

Test yourself

Take the HTML & CSS · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz