Learning HTML 3.2 by Examples, section 5 Descriptions of HTML 3.2 tags:

TEXTAREA - multi-line text input in a form


To specify, within a form, an area for multi-line user input.

Typical rendering

An input area which appears as a separate box, possibly having a distinct background color, and usually with some kind of scroll bars for both vertical and horizontal direction.

The area is initialized with the contents of the TEXTAREA element, using monospaced font. The contents is displayed as it is written, similarly to PRE elements.

Basic syntax

initial text

Possible attributes

attribute name possible values meaning notes
NAME string a property name that is used to identify the textarea field when the form is submitted to the server obligatory
ROWS integer number of visible text lines obligatory
COLS integer number of visible width of text, in average character widths obligatory

A browser should not interpret the ROWS and COLS attributes as restricting the size of the actual input. On the contrary, the browser should provide some means to scroll through the contents of the textarea field when the contents extend the visible area.

A browser may wrap visible text lines to keep long input lines visible without need for scrolling.

Allowed context

Text container, i.e. any element that may contain text elements. This includes most HTML elements. However, the text container must appear within a FORM element.


A string. Escape sequences are allowed, but no tags are recognized.

The contents is used to initialize the text that is shown in the input field when the document is first loaded.


    <TEXTAREA NAME=address ROWS=4 COLS=40>
    Your address here ...


See the description of the FORM element, which contains some examples of entire forms.

For single-line input fields you can use an INPUT element with TYPE=TEXT.

It is recommended in the specifications that browsers canonicalize line endings to CR, LF (ASCII decimal 13, 10) when submitting the contents of the field. However, authors should not rely on this, since not all browsers behave so. The character set for submitted data should be ISO Latin 1, unless the server has previously indicated that it can support alternative character sets.

The HTML specifications do not quite explicitly require that the contents of a TEXTAREA element (specifying the initial value) is to be rendered as it is written with respect to division into lines etc (similarly to PRE elements), but this is clearly the intention.

Typically browsers display the textarea content (both the initial content and the content entered by a user) in a fixed font. Although a TEXTAREA may occur within text level markup, it is thus usually not affected by it.

Browsers do not always honor the ROWS and COLS attributes exactly. Rather often the visible input area is somewhat larger than specified by them.

You cannot use ROWS and COLS attributes to restrict the size of the actual input, nor can you do that with other HTML constructs. The script that processes the form can be written so that it takes care of handling excessively large input if needed.

Date of last update: 2010-12-16.
This page belongs to the free information site IT and communication, section Web authoring and surfing, by Jukka "Yucca" Korpela.