HTML Tag Reference - HTML tag <textarea>








This <textarea> element creates a multiline text entry control. This element is usually used in conjunction with the <form> element.

Browser compatibility

<textarea> Yes Yes Yes Yes Yes

What's new in HTML5

HTML5 added several new attributes.

Attribute

Attribute Value Description
autofocus autofocus auto focus textarea
cols number Set the visible width of a textarea
disabled disabled Disable a textarea
form form_id Set one or more forms id
maxlength number Set the maximum number of characters allowed in the textarea
name text Set a name for a textarea
placeholder text Set hint text for textarea
readonly readonly Make textare read-only
required required Mark textarea as must-fill
rows number Set the visible number of lines in a text area
wrap hard
soft
how to wrap the text in a textarea when submitted in a form




Global Attributes

The <textarea> tag supports the Global Attributes in HTML.

Event Attributes

The <textarea> tag supports the Event Attributes in HTML.

Default CSS Settings

None.

Example

<html>
<body>
     <form>
          <fieldset align="center">
               <textarea name="textfield1" 
                         cols="40" wrap="hard">
                         your name and surname
               </textarea>
          </fieldset>
     </form>
</body><!--from  ww  w .  j a  v a  2  s  .c om-->
</html>

Click to view the demo





rows attribute

This attribute establishes the height of the element in terms of rows. The value is indicated by an integer.

<html>
<body>
     <form name="form1" method="post" action="">
     <!-- w  w w. j  a  v  a 2  s  .  c o  m-->
          <fieldset align="center">
               <textarea name="textfield1" 
                         cols="40" 
                         rows="2" 
                         wrap="hard">your name and surname</textarea>
               <br/>
          </fieldset>
    
     </form>
</body>
</html>

Click to view the demo