HTML <textarea> tag

The <textarea> tag is used to display a textarea. A textarea is a form element similar to the textbox but with more flexibility. A textarea allows more than a single line of text, and its width and height can be changed as well.

Attributes

Attribute Description Possible values
cols Required. Sets the number of columns in a textarea numColumns
rows Required. Sets the number of rows in a textarea numRows
disabled Sets a textarea to be disabled (will be grayed out and the user will not be able to edit it) disabled
name Sets the name of a textarea txtareaName
readonly Specifies that a textarea is read-only, meaning you can't change its content but only read what's already there readonly

Standard attributes

accesskey, class, dir, id, lang, style, tabindex, title, xml:lang

For more information on standard attributes, check out our HTML standard attributes reference page.

Event attributes

onblur, onchange, onclick, ondblclick, onfocus, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onkeydown, onkeypress, onkeyup, onselect

For more information on event attributes, check out our HTML event attributes reference page.

Example

<form> Name: <input type="text" name="name" /><br /> E-mail: <input type="text" name="email" /><br /> <textarea rows="10" cols="40 name="comments"> Your comments (enter them here) </textarea> <input type="submit" value="Submit" /> </form>
Output:
Name:
E-mail:

Tips & notes

Use the textarea when you want to receive data that may require a paragraph or two such as user feedback. You can use a textbox for the users name, another textbox for the users email address, and a textarea for the users feedback.

If you want some text to appear in a textarea when the page loads, include that text between the <textarea> and </textarea> tags. The above example demonstrates this concept.

Web Reference
  1. CSS reference
  2. RSS reference
  3. HTML reference


© Copyright 2011-2012 Landofcode.com
Terms of use | Privacy policy | Copyright information | Make a donation