In this tutorial, We will introduce you about the autofocus attribute of the <textarea> tag in html5. This attribute is used to specify that the control is focused when the page is loaded. The user need not any manual focus on the textarea before input in the textarea , It allow user to start typing after loading the page. Only one element have the autofocus in the document.
The attribute is used as in the <textarea> tag:
|<textarea autofocus="value">Text Here</textarea>|
This attribute have following possible values.
<title>Example of autofocus attribute</title>
<body>The textareas here.<br>
<textarea rows="5" cols="30">
This is the sample textarea with out autofocus.
<textarea rows="5" cols="30" autofocus="autofocus" >
This is the sample textarea with autofocus.
Difference between html4.01 and html5
This attribute is new in the html5.
Recommend the tutorial