You are here: Reference > JavaScript > client-side > HTML DOM > properties > rows (textarea)

rows property (textarea)

Browser support:
Sets or retrieves the number of visible rows within a textarea element.
The height is calculated by the average character heights. You can set the dimensions of textarea with the width and the height style properties.

Syntax:

object.rows;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: rows

Possible values:

Integer that sets or retrieves the number of visible rows.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the rows attribute:
<textarea rows="3">Some text content</textarea>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the rows property:
<head>
    <script type="text/javascript">
        function SetRows () {
            var input = document.getElementById ("myInput");
            var textArea = document.getElementById ("myTxtArea");
            textArea.rows = input.value;
        }
    </script>
</head>
<body>
    <textarea id="myTxtArea" rows="3">Some text content</textarea>
    <br />

    <input id="myInput" type="text" value="6" />
    <button onclick="SetRows ();">Set the number of rows!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content