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 automatic focus:
<button type="button" autofocus>Click me!</button>
Syntax
<button type="button" autofocus>
Browser support
The numbers in the table indicate the first browser version to fully support this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
5.0 | 10.0 | 4.0 | 5.0 | 9.6 |