Comment: In html 5, you can set the automatic focus to a certain control when the page is loaded. This is the autofocus property. Let’s introduce it in detail. Friends who need it can learn about it.
In html 5, you can set the autofocus property when the page is loaded, and this is the autofocus property, as follows:The code is as follows:
<input autofocus=autofocus />
<button autofocus=autofocus>Hi!</button>
<textarea autofocus=autofocus></textarea>
The browser supports this property:
fiefox 4+, safari 5+, chrome 6+, opera 11+, ie 10, and Android 2.3 and safari mobile 5- are not supported
Example
When the page loads, a button that gets focus:
The code is as follows:
<button type=button autofocus=autofocus>
Click here
</button>
Try it yourself
Definition and usage
The autofocus property specifies that the button should automatically gain focus when the page is loaded.
If you use this property, the button gets focus.
Differences between HTML 4.01 and HTML 5
The autoplay attribute is a new attribute in HTML 5.
grammar
The code is as follows:
<button autofocus=autofocus>