Skip to main content

no_autofocus

Enforce autofocus is not used on inputs. Autofocusing elements can cause usability issues for sighted and non-sighted users.

User impact: Serious

This rule supports the following configuration:

# The `autofocus` attribute must not be used.
no_autofocus = true

Success#

<!-- Good: No autofocus attribute -->
<!-- no_autofocus = true -->
<input type="text" name="username" />

Fail#

<!-- Bad: autofocus present -->
<!-- no_autofocus = true -->
<input type="text" name="username" autofocus />

Resources#