English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Comprehensive list of HTML tags

HTML: <textarea> autofocus attribute

The autofocus attribute is a boolean attribute, which specifies that the text area should automatically gain focus when the page is loaded.

 HTML <textarea> tag

Online example

An automatically focused text area:

<textarea rows="4" cols="50" autofocus>
At oldtoolbag.com will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 10, Firefox, Opera, Chrome, and Safari support the autofocus attribute.

Note:Internet Explorer 9 and earlier versions support the autofocus attribute of the <textarea> tag.

Definition and Usage

The autofocus attribute is a boolean attribute.

The autofocus attribute specifies that the text area should automatically receive focus when the page is loaded.

HTML 4.01 between5difference

The autofocus attribute is an HTML5 New attributes for the <textarea> tag.

Differences between HTML and XHTML

In XHTML, attribute shorthand is prohibited, and the autofocus attribute must be defined as <textarea autofocus="autofocus">.

Syntax

<textarea autofocus>
 HTML <textarea> tag