Home HTML Attributes rows HTML rows Attribute Definition
Definition and Usage The rows attribute on <textarea> sets how many visible text lines the control shows. If you specify it, the value must be a positive integer . If you omit it, the default is 2 .
Pair it with cols (visible width in average character widths; default 20 ) for a consistent starting size across browsers. Always use a proper <label>.
Baseline · Widely available. Not deprecated. Size hint only — it does not limit typed text. Not the same as table rowspan .
Syntax
HTML Syntax <textarea rows=" positive_integer ">…</textarea>
<textarea rows=" n " cols="m ">…</textarea>
In JavaScript: textarea.rows = 5. Initial text goes between the tags, not in a value attribute.
Values
Attribute Values One positive integer — visible line count:
Value Description Try it (omitted) Default visible height: 2 lines Try itrows="n"Show about n lines (n ≥ 1) Try itrows + colsHeight and width together for a stable box Try itrowspan (tables)Different attribute — cell spans table rows Try it
Try it
Live Preview Change rows and apply. The box grows or shrinks in visible lines — typing length is unchanged.
Code
HTML Examples Short demos. Use Try It Yourself for a live editor.
1. Basic rows 2. With cols 3. vs rowspan Example 1 — Basic rows Give a feedback box a taller visible area than the default two lines.
<label for="feedback">Feedback</label>
<textarea id="feedback" name="feedback" rows="5"></textarea> How It Works rows="5" asks for about five visible lines.Default without rows would be two lines.Label is tied with for / id for accessibility.Typing limit is separate — add maxlength if needed.Example 2 — rows with cols Set both dimensions so browser defaults do not surprise you.
<label for="story">Your story</label>
<textarea id="story" name="story" rows="6" cols="40">
It was a dark and stormy night…
</textarea> How It Works rows ≈ visible height in lines.cols ≈ visible width in average characters (default 20).Content between tags is the starting text.CSS can still refine layout; attributes give a solid baseline.Example 3 — rows ≠ rowspan Textareas use rows. Table cells that span vertically use rowspan.
<!-- textarea height -->
<textarea rows="3" cols="24">Notes</textarea>
<!-- table cell spanning two rows -->
<table border="1">
<tr>
<td rowspan="2">A</td>
<td>B</td>
</tr>
<tr><td>C</td></tr>
</table> How It Works rows = textarea visible lines.rowspan = how many table rows a cell covers.Similar names — different elements and jobs.Next topic rowspan covers table spanning in depth. Edge Cases & Pitfalls Most mistakes are treating rows as a text limit or confusing it with tables.
value Must be a positive integer Invalid or missing values fall back to browser defaults (typically 2 lines).
limit Not a character cap Use maxlength / minlength for length rules.
css CSS and resize can change the box Users may drag the corner; resize: none disables that. height can override the attribute visually.
tables Not rowspan Table spanning is a different attribute on td / th.
a11y Always label the control Placeholders are not a substitute for a visible <label>.
Compatibility
Browser Support rows is an HTML attribute on <textarea>. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
rows Supported everywhere modern forms work. Setting rows (and cols) avoids inconsistent browser defaults.
98% Global support (approx.)
Google Chrome Yes
Full support
Mozilla Firefox Yes
Full support
Apple Safari Yes
Full support
Microsoft Edge Yes
Full support
Opera Yes
Full support
Samsung Internet Yes
Full support
Internet Explorer Yes
Supported rows Widely supported
Bottom line: Safe to use. Prefer explicit rows + cols, then refine with CSS if needed.
Remember
Key Takeaways Role: visible line count on <textarea> (default 2).
Pair with cols for a predictable starting size.
Not a text limit — use maxlength for that.
Not rowspan — that is for tables.
One line: rows sets how many lines tall a textarea appears.
Frequently Asked Questions What does the HTML rows attribute do? On a textarea, rows sets how many lines of text are visible. If omitted, the default is 2. The value must be a positive integer when specified.
Which element uses rows? The textarea element. It is not for tables — table cells use rowspan to span multiple rows.
What is the difference between rows and cols? rows is the visible height in lines. cols is the visible width in average character widths (default 20). Use both for a predictable starting size.
Does rows limit how much text the user can type? No. It only affects the visible size. Use maxlength / minlength for length limits, or CSS for layout.
Can CSS override rows? Yes. A CSS height (or resize by the user) can change the rendered size. Still set rows for a sensible default before styles apply.
Is rows deprecated? No. It is a Baseline widely available attribute on textarea.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion