Introduction and Application of html5 button autofocus attributes

Source: Internet
Author: User

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">

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.