HTML | DOM Textarea rows Property
The DOM Textarea rows Property is used to set or return the value of a rows attribute of a textarea field. The rows attribute specify the number of visible text lines for the control i.e the number of rows to display.
Syntax:
- It is used to Return the rows property:
textareaObject.rows
- It is used to Set the rows property:
textareaObject.rows = number
Property Values:
- number: It specifies a visible number of rows in a textarea field.
Return Value: It returns a numeric value which represent the height of a textarea field contains the characters.
Example-1: HTML program to illustrate set the DOM Textarea rows Property.
<!DOCTYPE html> <html> <head> <title>DOM Textarea rows Property</title> <style> h1, h2 { text-align: center; } </style> </head> <body style="text-align:center;"> <h1 style="color: green;"> GeeksforGeeks </h1> <h2> DOM Textarea rows Property </h2> <!-- Below id assigned to Textarea Element --> <textarea id="GFG" rows="5" cols="23"> This paragraph has number of rows equal to 5. </textarea> <br> <button type="button" onclick="myGeeks()"> Submit </button> <script> function myGeeks() { // Access textarea element. document.getElementById("GFG").rows = "10"; } </script> </body> </html> |
Output :
Before Clicking On Button:

After Clicking On Button :

Example-2: HTML program to illustrate to return the DOM Textarea rows Property.
<!DOCTYPE html> <html> <head> <title>DOM Textarea rows Property</title> <style> h1, h2 { text-align: center; } </style> </head> <body style="text-align:center;"> <h1 style="color: green;"> GeeksforGeeks </h1> <h2> DOM Textarea rows Property </h2> <!-- Below id assigned to Textarea Element --> <textarea id="GFG" rows="5" cols="23"> This paragraph has number of rows equal to 5. </textarea> <br> <button type="button" onclick="myGeeks()">Submit</button> <p id="sudo"></p> <script> function myGeeks() { // Return number of rows in the textare. var x = document.getElementById("GFG").rows; document.getElementById("sudo").innerHTML = "There are" + x + " rows in a Textarea height."; } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browser supported by Textarea rows Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | <textarea> rows Attribute
- HTML | DOM Textarea name Property
- HTML | DOM Textarea autofocus Property
- HTML | DOM Textarea readOnly Property
- HTML | DOM Textarea defaultValue property
- HTML | DOM Textarea required Property
- HTML | DOM Textarea cols Property
- HTML | DOM Textarea placeholder Property
- HTML | DOM Textarea disabled Property
- HTML | DOM Textarea form Property
- HTML | DOM Textarea wrap Property
- HTML | DOM Textarea maxlength Property
- How to disable resizable property of textarea using CSS?
- HTML | <textarea> tag
- HTML | DOM Textarea Object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

