👀 Live Preview
Comments field with rows="5" and cols="40":

The rows attribute sets the visible height of a <textarea> in text lines. Use it to give users enough space for comments, feedback, or longer messages without relying on CSS alone. The default is 2 rows if you omit the attribute. Pair rows with cols for both height and width, or use CSS min-height for responsive layouts. Set textarea.rows in JavaScript to resize dynamically. Not the same as rowspan on table cells.
Visible height.
Only element.
Width & height.
If omitted.
JS property.
Not tables.
rows AttributeThe primary purpose of rows is to define how many lines of text are visible at once in a textarea. It sets the initial vertical size of the field so users can see more (or less) content before scrolling.
A contact form might use rows="4" for a short note and rows="10" for a detailed support ticket. Users can still type beyond the visible area — the field scrolls — but a well-chosen rows value improves the first impression of your form.
rows controls visible height in lines. cols controls visible width in character columns. Use both on the same <textarea> for a balanced default size. See the cols attribute guide.
Add rows to a <textarea> with a positive integer:
<label for="comments">Comments:</label>
<textarea id="comments" name="comments" rows="5"></textarea><textarea> elements.3, 8, 12).2 when the attribute is omitted.cols for width; use CSS for responsive sizing.textareaElement.rows = 10 (integer property).rowspan on <td> / <th>.The rows attribute accepts a positive integer representing visible text lines:
rows="2" — Default size; fine for one-line notes.rows="4" — Short feedback or comment fields.rows="8" — Medium messages, support requests.rows="12" or higher — Long-form text, drafts, descriptions.<textarea rows="3" cols="30">Short comment</textarea>
<textarea rows="6" cols="40">Standard message</textarea>
<textarea rows="12" cols="60">Long description</textarea>In rows="5", the browser renders the textarea tall enough to show approximately five lines of text at the default font size.
| Use Case | rows Value | Notes |
|---|---|---|
| Quick note | rows="2" | HTML default |
| Contact comment | rows="4" | Common form size |
| Support ticket | rows="8" | More visible space |
| Article body draft | rows="12"+ | Long-form writing |
| Width control | cols="40" | Pair with rows |
| Applicable element | <textarea> | Not input or table |
| Element | Supports rows? | Notes |
|---|---|---|
<textarea> | Yes | Primary and standard use |
<input> | No | Single-line only — use CSS height if needed |
<td>, <th> | No | Use rowspan for table cell merging |
<div> | No | rows is not a global height attribute |
rows vs rowspan| Aspect | rows on textarea | rowspan on table cells |
|---|---|---|
| Element | <textarea> | <td>, <th> |
| Purpose | Visible height in lines | Merge cells vertically |
| Value | Line count (e.g. 8) | Number of rows spanned (e.g. 2) |
| Context | Forms | HTML tables |
| JavaScript | textarea.rows | cell.rowSpan (camelCase) |
Form textarea sizing, dynamic textarea.rows in JavaScript, and comparing different row counts side by side.
Comments field with rows="5" and cols="40":
rowsGive users a taller area for comments in a simple form:
<form>
<label for="comments">Comments:</label>
<textarea id="comments" name="comments" rows="8"></textarea>
<input type="submit" value="Submit">
</form>rows="8" makes the textarea tall enough to show about eight lines before the user needs to scroll.
Adjust visible height programmatically with the rows property:
<textarea id="dynamicTextArea"></textarea>
<script>
document.getElementById("dynamicTextArea").rows = 10;
</script>textarea.rows accepts a positive integer. Useful when expanding a field after the user selects “Add more details” or similar.
Same width, different rows values:
<label>Short (3 rows)</label>
<textarea rows="3" cols="40"></textarea>
<label>Tall (10 rows)</label>
<textarea rows="10" cols="40"></textarea>Choose rows based on how much text you expect. Short fields feel compact; taller fields invite longer responses.
<textarea> with a visible <label> linked via for/id.rows as a character or line limit.resize: vertical lets users grow the field if they need more space.maxlength or server checks for input limits, not visible height.rows values can dominate small screens; balance with CSS max-height.Author picks visible line count in HTML.
Line height × rows ≈ field height.
Scroll appears when text exceeds visible lines.
Users see an appropriately sized writing area.
The rows attribute is supported in all modern browsers on <textarea> elements.
All major browsers honor rows for default textarea height.
textarea ExcellentBottom line: Safe to use for textarea height in all modern browsers.
rows to expected content length (short note vs long essay)cols or CSS width for a balanced textarearesize: vertical in CSS so users can expand if neededplaceholder and maxlength for clear form UXrows with rowspan on table cellsrows on <input> — it has no effectrows="1" when users need multiline inputrows alone for responsive design — add CSSrows limits how much users can type — it only affects visible heightThe rows attribute is a simple, effective way to set the initial visible height of a <textarea> in lines of text.
Choose a value that fits your form’s purpose, pair it with cols or CSS for width, and use textarea.rows in JavaScript when you need dynamic sizing.
rowsBookmark these when building forms.
Form fields.
ScopeVisible rows.
EffectIf omitted.
DefaultWidth too.
PairTables differ.
Gotcha<textarea> — the initial height of the field.rows, the default is 2 visible lines.rows sizes a textarea. rowspan merges table cells vertically — completely different.document.getElementById("myArea").rows = 10; — assign a positive integer to the rows property.maxlength to cap character count.rows on <textarea>.Set visible line count on <textarea> so forms feel right for the amount of text you expect.
5 people found this page helpful