Textarea rows property
Example
Modify the number of rows (height) of the textarea text box:
document
.
getElementById
(
"
myTextarea
"
)
.
rows
=
"
10
"
;
Try it »
Definition and Usage
The rows property sets or returns the value of the rows property of the textarea.
The rows property specifies the height (number of rows) of the text box.
Tip: You can use the style.heigth Property used to set the height of the textarea element.
Tip: You can use the cols and style.width Property used to set the width and height of the textarea element.
Browser support
| Property | |||||
|---|---|---|---|---|---|
| rows | Yes | Yes | Yes | Yes | Yes |
Syntax
Set the rows property:
textareaObject.rows=number
Return the rows property:
textareaObject.rows
Tip: The rows property has no default value.
Attribute values
| Value | Description |
|---|---|
| number | Specifies the number of visible rows in the text area |
Technical Details
| Return value: | A number, representing the height of the text box. |
|---|
More examples
Example
Get the height of the textarea element (the value of the rows property):
var
x
=
document
.
getElementById
(
"
myTextarea
"
)
.
rows
;
Try it »
Example
Use style.height to modify the height of the textarea element:
document
.
getElementById
(
"
myTextarea
"
)
.
style
.
height
=
"
250px
"
;
Try it »
Example
Use the cols and rows properties of the textarea element to modify the height and width:
document
.
getElementById
(
"
myTextarea
"
)
.
rows
=
"
10
"
;
document
.
getElementById
(
"
myTextarea
"
)
.
cols
=
"
100
"
;
Try it »
The Textarea object