Latest web development tutorials

HTML button autofocus attribute

HTML button labels Reference Manual HTML <button> tag

Examples

Use autofocus button properties:

<button type="button" autofocus>点我!</button>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Firefox, Chrome, and Safari support autofocus attribute.

Note: Internet Explorer 9 and earlier versions of IE do not support autofocus attribute.


Definition and Usage

autofocus attribute is a boolean (Boolean) property.

Autofocus attribute specifies when the page is loaded buttons should automatically get focus.


Differences between HTML 4.01 and HTML5

autofocus property is a new property HTML5 <button> tag.


Differences between HTML and XHTML

In XHTML, allowed attribute shorthand, autofocus attribute must be defined as <button autofocus = "autofocus">.


grammar

<button type="button" autofocus>


HTML button labels Reference Manual HTML <button> tag