textarea Element


 

Module

The textarea element is an inline element declared by the XHTML 1.1 Forms Module

Elements in the Forms Module are:
form | label | textarea | select | optgroup | option | button | fieldset | legend |
input type="button" | input type="checkbox" | input type="file" | input type="hidden" | input type="image" | input type="password" | input type="radio" | input type="reset" | input type="submit" | input type="text"

Description

The textarea element is used within a form to provide a text box in which the user may enter a block of text. The width and height of the textarea must be specified using the compulsory cols and rows attributes respectively.

Any text enclosed within the textarea element in the markup is placed within the text box when the form is first rendered. The user may then edit the text (provided the textarea is not disabled or readonly) and the final edited text is sent to the processing URI as the value in a name=value pair.

Here is an example textarea:

<label for="msg">Your Message:</label><br />
<textarea cols="25" rows="6" id="msg" name="message">Enter your message here.</textarea>

This renders as:


See also the input type="text" element for the input of shorter text.

#REQUIRED Attributes

The cols and rows attributes are #REQUIRED on the textarea element.


Specific Attributes

Specific attributes of the textarea element are listed below:

From the Forms Module - the Element's own Module

accesskey [ type Character ]
Key to be pressed which allows focus to be directed immediately to this textarea element to allow text input
cols [ type Number - #REQUIRED ]
Width of the textarea in characters (based on an average character width)
disabled [ type Boolean ]
If this attribute is present, the textarea is initially disabled - no data is sent to the processing URI for disabled elements when the form is submitted. The user cannot interact with a disabled control.
name [ type CDATA ]
This is the name sent to the processing URI for the textarea when the form is submitted (if the name attribute is not present, the textarea data will not be sent). The value sent (in a name=value pair) is the text within the textarea at the time of submission (the initial value of the textarea - to which it is returned if the form is reset - is the content of the textarea element in the markup)
readonly [ type Boolean ]
If this attribute is present, the text within the textarea may not (initially) be modified by the user. Data may still be sent to the processing URI for readonly textareas.
rows [ type Number - #REQUIRED ]
Number of visible rows (lines) of text in the textarea
tabindex [ type Number ]
An integer between 0 and 32767 specifying the position of the textarea in the tabbing order of the document

From the Intrinsic Events Module

onblur [ type Script ]
Script to be executed when the element loses focus
onchange [ type Script ]
Script to be executed if the text within the textarea has been changed (it is triggered only when the element loses focus and its content has changed since last gaining focus)
onfocus [ type Script ]
Script to be executed when the element receives focus
onselect [ type Script ]
Script to be executed when some text within the textarea is highlighted

Common Attributes

Common attributes of the textarea element are listed below:

From the Core Attribute Collection

class [ type NMTOKENS ]
One or more space separated classes
id [ type ID ]
A unique identifier for the element
style [ type CDATA ], from the Style Attribute Module (deprecated)
Element-specific styles
title [ type Text ]
Descriptive title for the element (in some user agents this may appear as a "tooltip" when the mouse hovers over the element)
xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]
XML namespace

From the I18N Attribute Collection

dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Module
Left-to-right or right-to-left directionality
xml:lang [ type LanguageCode ]
A language code for the element

From the Events Attribute Collection

All attributes in the Events Attribute Collection are supported:
onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup


Content Model

The Content Model for the textarea element is:

#PCDATA

See Content Model & Nesting for information about Content Model syntax and Nesting Groups.

Valid children of textarea

Valid parents of textarea


Page Footer & Copyright

Copyright © Sally Maughan 2005-2009 (Page last updated on 01 Oct 2009)

*Valid XHTML 1.1 - hosted by *Openstrike

Content based on the W3C Working Draft: *XHTML 1.1 and Recommendation: *XHTML Modularisation 1.1.

W3C, XHTML, XML, HTML, CSS and MathML are *Trademarks of the W3C (*MIT, *ERCIM, *Keio) with which the site's author has no connection.


Up, Next & Previous Links

Your Location

Home > XHTML 1.1 Home > XHTML 1.1 Indexes > Element Index (XHTML 1.1) > textarea Element