If I have a form that is the main part of a page's content, will assigning focus to the first form field via JavaScript on page load have any negative effects on accessibility?
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.
Understanding Focus In most browsers, users can move focus by pressing the Tab key and the Shift + Tab keys. The following elements can receive focus: <a> tags with an href attribute. Form controls and buttons (unless the element is disabled)
Focus is defined as the control on the computer screen that receives input from the keyboard (typing) and clipboard (when you paste text). When you focus an element, you'll often see special styling outlining the text field box, called the focus ring.
You can disable it easily. Go to the Advanced → Form tab and uncheck the box Autofocus on the first input field of the form.
The short answer is no it doesn't make things inaccessible but it can make it confusing. The longer answer follows. Will your users know that there going to a page with a form, and does there need to be any descriptive text you should read before filling out the form? I'm a screen reader user and it can be annoying having focused put in random fields. It's clear why your focus winds up in the Google search box so that doesn't bother me. If my focus were automatically placed in the answer edit field every time I viewed a question on Stackoverflow I would be annoyed since I'd have to force my screen reader to navigate away from the form field and to the top of the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With