Comments: In html 5, you can set the automatic focus to reach a control when the page is loaded. This is the autofocus attribute. Next we will introduce it in detail, if you have any requirements, you can understand that in html 5, you can set the automatic focus to reach a control when the page is loaded. This is the autofocus attribute, as shown below:
The Code is as follows:
<Input autofocus = "autofocus"/>
<Button autofocus = "autofocus"> Hi! </Button>
<Textarea autofocus = "autofocus"> </textarea>
The browser supports the following attributes::
Fiefox 4 +, safari 5 +, chrome 6 +, opera 11 +, ie 10, not supported by android 2.3 and safari mobile 5
Instance
When a page is loaded, a button with the focus will be obtained:
The Code is as follows:
<Button type = "button" autofocus = "autofocus">
Click here
</Button>
Try it yourself
Definition and usage
The autofocus attribute specifies that when a page is loaded, the button should automatically obtain the focus.
If this attribute is used, the button gets the focus.
Differences between HTML 4.01 and HTML 5
The autoplay attribute is a new attribute in HTML 5.
Syntax
The Code is as follows:
<Button autofocus = "autofocus">