Skip to content

Latest commit

 

History

History
17 lines (11 loc) · 525 Bytes

autofocus-a-form-field.md

File metadata and controls

17 lines (11 loc) · 525 Bytes

Autofocus a Form Field

autofocus is a global attribute that sets a field as focused on page load.

<input name="first_name" autofocus />

No JavaScript required!

A use case could be a new customer form that an employee fills out multiple times a day. By autofocusing the first name field, you could save that employee thousands of clicks.

Carefully consider user experience and accessibility before using this attribute.

Docs: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus