Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <textarea> autofocus Attribute

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.

Example

#

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>

Using autofocus

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.


Syntax

<textarea autofocus>

Browser support

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

You may also like

 Back to <textarea>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides