The autofocus
attribute on a <textarea> tag
specifies that the textarea has focus once the page is loaded.
Focus means that keyboard text input is directed to that control.
A <textarea> with autofocus enabled. This control has focus and displays the blinking text entry cursor.
<form action="/tutorial/action.html">
<textarea autofocus rows="3" cols="50" name="message"
placeholder="Enter your message"></textarea>
<br/><br/>
<input type="submit">
</form>
The autofocus
attribute sets focus to the textarea 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.
<textarea autofocus>
Here is when autofocus support started for each browser:
Chrome
|
1.0 | Sep 2008 |
Firefox
|
4.0 | Mar 2011 |
IE/Edge
|
10.0 | Sep 2012 |
Opera
|
1.0 | Jan 2006 |
Safari
|
1.0 | Jan 2003 |
Back to <textarea>