The initial focus is a technique that is used to set the focus on a particular element when any application
or website is loaded. For example, when a user opens a form on a website, the initial focus might be set on
the first input field of the form instead of the start of the page.
NOTE:
New to accessibility or uncertain of requirements, it will be helpful to review all sections below.
Already familiar with requirements, skip to the “Working Example” section for sample HTML, CSS
and JavaScript (when needed), along with a working demo.
Identify and consider the importance of content on the page while setting the initial focus.
Use HTML markup, JavaScript, or other programming techniques to set the initial focus when the page
loads.
Ideally, the initial focus MUST be set on the beginning of the page or the first
interactive element such as “Skip to main content” link when a page loads.
If user attention by design needs to be drawn to a specific element when a page loads, such as a username
field on a login page, set initial focus on that element using HTML autofocus attribute.
Alternatively, we can use JavaScript HTMLElement.focus() or .focus()
method to set focus on the desired interactive element on the webpage on page load.
Setting initial focus logically could benefit majorly the below users.