<textarea>

Browser
  • IE
  • Cr
  • Sf
  • Fx
  • O
Type

The TEXTAREA element defines a multi-line text area.


<textarea name="example1" cols="50" rows="5"></textarea>

<textarea name="example2" cols="50" rows="5" wrap="hard">initial text</textarea>

Attribute Value Explanation
name=" " field name a unique name for the field
cols=" " number the number of visible columns
rows=" " number the number of visible rows
wrap=" "
(Extension)
hard the input text is wrapped
(and the submitted text contains line breaks)
soft the input text is wrapped
(but the submitted text doesn't contain line breaks)
off the input text is not wrapped
name=""
The field name is used to identify the form field.
cols=""
Specifies the number of visible columns in the text area. (The text area's width)
rows=""
Specifies the number of visible rows in the text area. (The text area's height)
wrap=""

The wrap attribute controls how the text should wrap at the end of lines.

hard : The input text is wrapped within the text area. (The text submitted to the server contains line breaks.)

soft : The input text is wrapped within the text area. (The text submitted to the server doesn't contain line breaks.)

off : The input text is not wrapped.

The initial text in the text area

The content of the TEXTAREA element is the text area's initial text.

<textarea name="example" cols="20" rows="3" wrap="hard">The initial text</textarea>

Example


<form method="POST" action="example.cgi">

<p>cols:30, rows:5<br>
<textarea name="comment1" cols="30" rows="5"></textarea></p>

<p>The initial text<br>
<textarea name="comment2" cols="30" rows="5">
The initial text
in the text area
</textarea></p>

</form>

Output

cols:30, rows:5

The initial text

This form cannot submit because of a sample.