This attribute is useful for transferring the focus to a field other than the first field in a page/form (by default the first input field has the focus).
Attention: there must not be more than one element in the document with the autofocus attribute specified!
This example below illustrates the use of the autofocus attribute: the focus is put on the second input field of the page. It also shows the use of required, placeholder and pattern attributes.
The required attribute makes the input field invalid if kept empty.
Extract from source code:
<form>
...
<input type="text" id="test"/><p>
...
<input id="name" name="inputName"
placeholder="6 to 9 chars please..."
pattern="\w{6,9}"
required
autofocus
type="text"/>
...
</form>
Read these explanations for a complete description of the syntax of Boolean attributes.