Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is automatically assigning focus bad for accessibility?

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?

like image 743
racurry Avatar asked Feb 01 '10 22:02

racurry


People also ask

Is autofocus bad for 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.

How do you manage focus accessibility?

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)

What is focus in accessibility?

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.

How do you prevent automatic focus on first input field?

You can disable it easily. Go to the Advanced → Form tab and uncheck the box Autofocus on the first input field of the form.


1 Answers

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.

like image 111
Jared Avatar answered Oct 01 '22 02:10

Jared