NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.

HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<textarea> (Multiline Text Input)

This element specifies a multiline text input field contained within a form.

Standard Syntax

class="class name"
dir="ltr | rtl"
id="unique alphanumeric identifier"
lang="language code"
name="unique alphanumeric identifier"
style="style information"
title="advisory text"

Attributes Defined by Internet Explorer

contenteditable="false | true | inherit" (5.5)
datafld="column name" (4)
datasrc="data source ID" (4)
hidefocus="true | false" (5.5)
language="javascript | jscript | vbs | vbscript" (4)
wrap="off | physical | virtual" (4)

Attributes Defined by Netscape 4

wrap="hard | off | soft"

Standard Event Attributes

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

Events Defined by Internet Explorer

onactivate, onafterupdate, onbeforeactivate, onbeforecopy, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, oncontextmenu, oncontrolselect, oncopy, oncut, ondeactivate, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerrorupdate, onfilterchange, onfocus, onfocusin, onfocusout, onhelp, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresize, onresizeend, onresizestart, onselectstart, ontimeerror

Element Specific Attributes

This Microsoft-specific attribute specifies a keyboard navigation accelerator for the element. Pressing ALT or a similar key in association with the specified character selects the form control correlated with that key sequence. Page designers are forewarned to avoid key sequences already bound to browsers.

This attribute sets the width in characters of the text area. The typical default values for the size of a <textarea> element when this attribute is not set is 20 characters.

This attribute is used to indicate the column name in the data source that is bound to the content enclosed by the <textarea> element.

The value of this attribute is an identifier indicating the data source to pull data from.

This attribute is used to turn off a form control. Elements will not be submitted nor can they receive any focus from the keyboard or mouse. Disabled form controls will not be part of the tabbing order. The browser also can gray out the form that is disabled in order to indicate to the user that the form control is inactive. This attribute requires no value.

This attribute allows a form control to be assigned a name so that it can be referenced by a scripting language. name is supported by older browsers, such as Netscape 2 generation browsers, but the W3C encourages the use of the id attribute. For compatibility purposes, both attributes might have to be used.

This attribute prevents the form control's value from being changed. Form controls with this attribute set might receive focus from the user but might not be modified. Because they receive focus, a readonly form control will be part of the form's tabbing order. Finally the control's value will be sent on form submission. The attribute can be used with <input> only when type is set to text or password. The attribute also is used with the <textarea> element.

This attribute sets the number of rows in the text area. The value of the attribute should be a positive integer.

This attribute takes a numeric value indicating the position of the form control in the tabbing index for the form. Tabbing proceeds from the lowest positive tabindex value to the highest. Negative values for tabindex will leave the form control out of the tabbing order. When tabbing is not explicitly set, the browser can tab through items in the order they are encountered. Form controls that are disabled due to the presence of the disabled attribute will not be part of the tabbing index, although read-only controls will be.

In some versions of Netscape and Microsoft browsers, this attribute controls word-wrap behavior. A value of off for the attribute forces the <textarea> not to wrap text, so the viewer must manually enter line breaks. A value of hard causes word wrap and includes line breaks in text submitted to the server. A value of soft causes word wrap but removes line breaks from text submitted to the server. Internet Explorer supports a value of physical, which is equivalent to Netscape's hard value, and a value of virtual, which is equivalent to Netscape's soft value. If the wrap attribute is not included, text will still wrap under Internet Explorer, but older versions of Netscape, notably Netscape 4, will scroll horizontally in the text box. Given this problem, even though it is nonstandard, it may be a good idea to include the wrap attribute.


<textarea name="CommentBox" cols="40" rows="8">
Default text in field

<textarea name="comment" rows="10" cols="40"
 wrap="virtual" align="center">


HTML 2, 3.2, 4, 4.01, XHTML 1.0, 1.1
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 1, 2, 3, 4, 4.5-4.8, 6, 7
Opera 4-7


Any text between the <textarea> and </textarea> tags is rendered as the default entry for the form control. Content within a textarea is not interpreted, so white space is preserved and tags themselves are ignored.

The HTML 2.0 and 3.2 specifications define only the cols, name, and rows attributes for this element.

The textarea element lacks a maxlength attribute, which causes a potential security risk. Potential intruders to a site may copy and paste large amounts of text or script code into a textarea element in an attempt to break a Web application. All submissions from a textarea should be checked carefully to avoid security risks.

The HTML 4.01 specification reserves the datafld and datasrc attributes for future use with the textarea element.

(X)HTML Elements
CSS Properties
Previous: td Next: tfoot
< Home | About | Chapters | Examples | Errata | Reference | Site Map >