Textarea rows attribute

Definition and Usage

rows attribute to set or return the value of the text area's rows attribute.

The HTML rows attribute specifies the height of the text area (number of visible lines).

Tip:You can also use style.height attribute to set the height of the text area.

Tip:Use cols or style.width attribute to change the width of the text area.

See also:

HTML Reference Manual:HTML <textarea> rows Atribute

Example

Example 1

Change the number of visible lines in the text area:

document.getElementById("myTextarea").rows = "10";

Try it yourself

Example 2

Get the height of the text area, in characters:

var x = document.getElementById("myTextarea").rows;

Try it yourself

Example 3

Use the style.height property to change the height of the text area:

document.getElementById("myTextarea").style.height = "250px";

Try it yourself

Example 4

Use the cols and rows attributes to change the height and width of the text area:

document.getElementById("myTextarea").rows = "10";
document.getElementById("myTextarea").cols = "100";

Try it yourself

Example 5

Use the style.width and style.height properties to change the height and width of the text area:

document.getElementById("myTextarea").style.height = "100px";
document.getElementById("myTextarea").style.width = "500px";

Try it yourself

Syntax

Return the rows attribute:

textareaObject.rows

Set the rows attribute:

textareaObject.rows = number

Attribute Value

Value Description
number Specifies the number of visible lines in the text area.

Technical Details

Return Value: Number, representing the height of the text area in characters.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support