Last Updated : 11 Jul, 2025
The rows attribute in HTML is used to specify the number of visible text lines for the control i.e the number of rows to display.
Note: This attribute is only applicable on <textarea>.
Syntax:
<textarea rows = "value">Text content...</textarea>
Attribute Values:
Its default value is 2. It contains a numeric value that specifies the height of the textarea element.
Example: In this example uses the rows attribute in a <textarea> element, setting it to display 5 rows of text. The content inside is displayed within the specified height.
html
<!DOCTYPE html>
<html>
<head>
<title>HTML rows Attribute</title>
<style>
h1,
h2 {
text-align: center;
}
</style>
</head>
<body>
<center>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h2>
HTML rows Attribute
</h2>
<!-- Below Textarea element has rows
attribute assigned to 5 -->
<textarea rows="5" cols="23">
This paragraph has a number of rows equal to 5.
</textarea>
</center>
</body>
</html>
Output:
Supported Browsers: The browser supported by rows attribute are listed below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4