Textarea rows attribute
Definition and Usage
rows
Property 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 Attribute
Example
Example 1
Change the number of visible lines in the text area:
document.getElementById("myTextarea").rows = "10";
Example 2
Get the height of the text area, in characters:
var x = document.getElementById("myTextarea").rows;
Example 3
Use the style.height property to change the height of the text area:
document.getElementById("myTextarea").style.height = "250px";
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";
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";
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 |