Home Tutorial Html Html5 html5 autofocus attribute, Example of autofocus attribute of <textarea> tag in html5

 
 

Share on Google+Share on Google+
html5 autofocus attribute, Example of autofocus attribute of <textarea> tag in html5
Posted on: September 17, 2010 at 12:00 AM
Advertisement
In this tutorial, We will introduce you about the autofocus attribute of the <textarea> tag in html5.

html5 autofocus attribute, Example of autofocus attribute of <textarea> tag in html5

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.

Declaration Syntax:  

The attribute is used as in the <textarea> tag:

<textarea autofocus="value">Text Here</textarea>

This attribute have following possible values.

  • autofocus.  e.g.     autofocus="autofocus"
  • empty string.         autofocus=" "
  • empty                   autofocus

Example: autofocus_attribute.html

<!DOCTYPE html>
<html>
  <head>
      <title>Example of autofocus attribute</title>
  </head>
   <body>The textareas here.<br>
   <form>
        <textarea rows="5" cols="30">
    This is the sample textarea with out autofocus.
    </textarea><br><br>
     <textarea rows="5" cols="30" autofocus="autofocus" >
    This is the sample textarea with autofocus.
    </textarea><br>
   </form>
  </body> 
</html>

Output:

Download This Example:

Difference between html4.01 and html5

This attribute is new in the html5.

Advertisement

Related Tags for html5 autofocus attribute, Example of autofocus attribute of <textarea> tag in html5:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: September 17, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com