Comments: HTML5 brings us a lot of amazing things. Previous tasks that need to be completed using JavaScript and Flash, such as form verification, INPUT placeholders, client renaming and downloading files and audio/video, can be completed using basic HTML
A simple HTML5 function is to let the input focus automatically fall into an element when the page is loaded. This action is completed using the autofocus attribute.
HTML code is very simple:
The Code is as follows:
<! -- These all work! -->
<Input autofocus = "autofocus"/>
<Button autofocus = "autofocus"> Hi! </Button>
<Textarea autofocus = "autofocus"> </textarea>
When the autofocus attribute is available, all the INPUT, TEXTAREA, or BUTTON elements can be loaded on the page and selected. However, if you use a pure display element, such as the H1 tag, the autofocus attribute is not easy to use.
This attribute is useful in some cases. For example, on Google's homepage, people use it for 99% of their time. Therefore, once a page is loaded, the cursor must be positioned in the input box. In the past, JavaScript was required. Now, html can be completed without any need.