html text area

HTML Textarea

The HTML <textarea> tag is used to define a multi-line text input control.

It can hold unlimited number of characters and the texts are displayed in a fixed-width font (usually courier).

The size of the HTML textarea is defined by <cols> and <rows> attribute, or it can also be defined through CSS height and width properties.


HTML Textarea Example

  1. <textarea rows=“9” cols=“70”>  
  2. JavaTpoint textarea tag example with rows and columns.  
  3. </textarea>  

Test it Now

Output:


Supporting Browsers

Element chrome browser Chrome ie browser IE firefox browser Firefox opera browser Opera safari browser Safari
<textarea> Yes Yes Yes Yes Yes

New HTML 5 Textarea Attributes

Attribute Description
autofocus It specifies that a text area should be automatically get focused when the page is loaded.
form It specifies one or more forms the textarea belongs to.
maxlength It specifies the maximum number of characters allowed in the text area.
placeholder It specifies a short hint that describes the expected value of a textarea.
required It specifies that textarea must be filled out.
wrap It specifies that how the texts in the textarea are wrapped at the time of the submission of the form.

HTML Textarea form attribute

The form attribute specifies one or more forms the text area belongs to.

  1. <form action=“updates.jsp” id=“usrform”>  
  2.  Name: <input type=“text” name=“usrname”>  
  3.  <input type=“submit”>  
  4. </form>  
  5. <br>  
  6. <textarea rows=“9” cols=“70” name=“comment” form=“usrform”>  
  7. Enter text here…</textarea>  
  8. <p>The text area above is outside the form element, but should still be a part of the form.</p>  
  9. <p><b>Note:</b> The form attribute is not supported in Internet Explorer.</p>  

Test it Now

Output:

Name:  

The textarea element above is outside the form , but it is still the part of the form.

Note: The form attribute is not supported in Internet Explorer.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s