- Is autofocus bad for accessibility?
- Why avoid autofocus?
- What does autofocus do in HTML?
- How does autofocus work?
Is autofocus bad for accessibility?
Accessibility considerations
Automatically focusing a form control can confuse visually-impaired people using screen-reading technology and people with cognitive impairments. When autofocus is assigned, screen-readers "teleport" their user to the form control without warning them beforehand.
Why avoid autofocus?
Autofocus can create confusion, especially for screenreader users, by moving them to a form field without permission or context. When the page <input> includes other content, or when the input field isn't the primary purpose of the page, it's best practice to let visitors choose to fill out a form.
What does autofocus do in HTML?
The autofocus attribute is a boolean attribute. When present, it specifies that the element should automatically get focus when the page loads.
How does autofocus work?
The process of autofocusing generally works as follows: (1) An autofocus processor (AFP) makes a small change in the focusing distance. (2) AFP reads the AF sensor to assess whether and by how much focus has improved. (3) Using the information from (2), the AFP sets the lens to a new focusing distance.