The autofocus
attribute on
an <input> tag specifies that the input element
has focus once the page is loaded.
Focus means that all text input goes into that control.
A <input> element with autofocus enabled. This control has focus and displays the blinking text entry cursor.
<form action="/tutorial/action.html">
<input autofocus type="text" placeholder="Enter your name"
name="name" autofocus><br /><br />
<input type="submit">
</form>
The autofocus
attribute sets focus to the input element upon page load.
Only a single element on a page can have focus.
Therefore, only one element on a page can have the autofocus
attribute.
<input autofocus>
Here is when autofocus support started for each browser:
Chrome
|
5.0 | May 2010 |
Firefox
|
4.0 | Mar 2011 |
IE/Edge
|
11.0 | Oct 2013 |
Opera
|
9.6 | Oct 2008 |
Safari
|
5.0 | Jun 2010 |