HTML DOM Textarea rows Property

Textarea Object : Change the number of visible rows for a text area

Definition and Usage

The rows property sets or returns the value of the rows attribute of a text area.

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

Tip: You can also use the style.height property to set the height of a text area.
Tip: Use the cols property, or the style.width property to change the width of a text area.

Browser Support

Property
rows Yes Yes Yes Yes Yes

Syntax

Return the rows property:

textareaObject.rows

Set the rows property:

textareaObject.rows = number

Property Values

Value Description
number Specifies the visible number of rows in the text area

Technical Details

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

More Examples

Example

Get the height of a text area, in characters:

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

Example

Change the height of a text area using the style.height property:

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

Example

Change the height and width of a text area using the cols and rows properties:

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

Example

Change the height and width of a text area using the style.width and style.height properties:

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

Related Pages

HTML reference: HTML <textarea> rows attribute

❮ Textarea Object