Skip to content

Latest commit

 

History

History
28 lines (18 loc) · 898 Bytes

no-autofocus-attribute.md

File metadata and controls

28 lines (18 loc) · 898 Bytes

no-autofocus-attribute

✅ The extends: 'recommended' property in a configuration file enables this rule.

The autofocus attribute is a global attribute that indicates an element should be focused on page load. Autofocus reduces accessibility by moving users to an element without warning and context. Its use should be limited to form fields that serve as the main purpose of the page, such as the search input on the Google home page.

Examples

This rule allows the following:

<input type="text" />

This rule forbids the following:

<input type="text" autofocus />
<input type="password" autofocus="autofocus" />

References