HTML <button> autofocus Attribute

Definition and Usage

autofocus The attribute is a boolean attribute.

If this attribute is set, it specifies that the button should automatically receive focus when the page is loaded.

Example

Button with Autofocus:

<button type="button" autofocus>Click Me!</button>

Try It Yourself

Syntax

<button type="button" autofocus>

Browser Support

The numbers in the table indicate the first browser version to fully support this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
5.0 10.0 4.0 5.0 9.6