HTML and buttons and autofocus properties

HTML button autofocus property HTML slt;button-and-label

The autofocus property is set with a button that automatically gets focus after the page loads, refer to the following example:

Buttons use autofocus properties:

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

Try it out . . .

Browser support

HTML button autofocus property HTML button autofocus property HTML button autofocus property HTML button autofocus property HTML button autofocus property

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

Note: Autofocus properties are not supported by Internet Explorer 9 and earlier versions of IE.


Definitions and usages

The autofocus property is a boolean property.

The autofocus property states that the button should automatically get focus when the page loads.

Tips:


The difference between HTML 4.01 and HTML5

The autofocus property is the new property of the HTML5 and lt;button.gt; tags.


The difference between HTML and XHTML

In XHTML, properties are not allowed to be short-written, and autofocus properties must be defined as .lt;button autofocus."autofocus"."


Grammar

<button type="button" autofocus>

HTML button autofocus property HTML slt;button-and-label