autofocus
autofocus
This page has been flagged with the following issues:
High-level issues:
Summary
Provides a way to direct a user to a specific field when a document loads. This can provide both direction and convenience for a user, reducing the need to click or tab to a field when a page opens. This attribute is true when present on an element, and false when missing.
| Applies to | ? |
|---|
This is the one of the important attribute introduced in HTML5 in terms of UX. With this attribute we can focus required element without any JavaScript code. And all you need to do is place one attribute to HTML element.
For example if we look at Facebook home page you can see that cursor is automatically pointed to email id field which makes user to just type in the credentials.
Let's have an example for the same.
<input id="search_box" autofocus>
Needs Examples: This section should include examples.
Notes
Remarks
Only one control in a document can have autofocus specified. If more than one element has the attribute, only the first one in the page will get the focus when the page opens. This is a boolean attribute, requiring only the presence of the attribute to be true. The following example shows a field that will receive focus when a page opens. Note For more code samples, see Form controls part 1 and Form controls part 2: validation on the Windows Internet Explorer sample site.
Syntax
Standards information
- HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 4.10.19.4
Compatibility
Desktop
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| Basic Support | 6+ | 4+ | 10 | 11+ |
5+ |
Mobile
| Feature | Android | BlackBerry | Chrome for mobile | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Opera Mini | Safari Mobile |
|---|---|---|---|---|---|---|---|---|
| Basic support | ? | ? | ? | ? | ? | ? | ? | ? |
See also
External resources
Related pages (MSDN)
This article contains content originally from external sources.
Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]
This tool helps to make and review comments inline.
How to Use
insert instructions, with images, here