HTML <button> autofocusAttribute
Example
A button using the autofocus attribute:
<button type="button" autofocus>Click me!</button>
Try it yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
Internet Explorer 10, Firefox, Chrome, and Safari support the autofocus attribute.
Note:Internet Explorer 9 and earlier IE versions do not support the autofocus attribute.
Definition and Usage
The autofocus attribute is a boolean attribute.
The autofocus attribute specifies that a button should automatically get focus when the page loads.
Differences between HTML 4.01 and HTML5
The autofocus attribute is new in HTML5 for the <button> tag.
Differences between HTML and XHTML
In XHTML, attribute minimization is not allowed, and the autofocus attribute must be defined as <button autofocus="autofocus">.
Syntax
<button type="button" autofocus>
HTML <button> Tag Other Extensions