THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Textarea rows Property

Textarea Object Reference Textarea Object

Example

Change the number of visible rows for a text area:

document.getElementById("myTextarea").rows = "10";
Try it Yourself »

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

Internet Explorer Firefox Opera Google Chrome Safari

The rows property is supported in all major browsers.


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;

The result of x will be:

4
Try it Yourself »

Example

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

document.getElementById("myTextarea").style.height = "250px";
Try it Yourself »

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";
Try it Yourself »

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";
Try it Yourself »

Related Pages

HTML reference: HTML <textarea> rows attribute


Textarea Object Reference Textarea Object