HTML and CSS Reference
3.9 Autofocusing a Form Field
You want to place the focus in a particular form field when a page loads.
Apply the HTML5 autofocus attribute to only one form field:
<p><label>Search <input type="search" name="query" autofocus ></label></p>
Autofocus behavior on the Web is alternately loved or hated. It's great when the search
box on Google is autofocused, but it's roundly hated when the user expects to be able
to scroll a page by pressing the down arrow key but the page has autofocused in a field.
accessible. When implementing the autofocus attribute, remember that it may be
specified only once per document , not per form! To maintain accessibility, a user agent
may honor a user setting or action that would override the focus action.
If a user agent does not recognize the autofocus attribute, it will be ignored. You can
For a browser support reference of autofocus , please see Table 3-9 .
Table 3-9. Browser support for the autofocus attribute
10 Platform Preview 2
See Recipe 3.14 , for details.
3.10 Displaying Placeholder Text
You want to display some hint or help text within a form field.