rows Attribute of Textarea
Example
Modify the number of rows (height) of a textarea:
document.getElementById("myTextarea").rows = "10";
Definition and Usage
The rows attribute sets or returns the value of the rows attribute of a textarea.
The rows attribute specifies the height of the text box in rows.
Tip: You can use the style.height property to set the height of the textarea element.
Tip: You can use the cols and style.width properties to set the width and height of the textarea element.
Browser Support
| Property | |||||
|---|---|---|---|---|---|
| rows | Yes | Yes | Yes | Yes | Yes |
Syntax
Set the rows attribute:
textareaObject.rows = number
Return the rows attribute:
textareaObject.rows
Tip: The rows attribute has no default value.
Attribute Values
| Value | Description |
|---|---|
| number | Specifies the number of visible lines in the text area |
Technical Details
| Return Value: | A number representing the height of the text box. |
More Examples
Example
Get the height (value of the rows attribute) of a textarea element:
var x = document.getElementById("myTextarea").rows;
Example
Modify the height of a textarea element using style.height:
document.getElementById("myTextarea").style.height = "250px";
Example
Modify the height and width using the cols and rows attributes of a textarea element:
document.getElementById("myTextarea").rows = "10";
document.getElementById("myTextarea").cols = "100";