Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

rows — visible textarea lines

The rows attribute specifies how many lines a textarea shows. It requires a positive integer; the default character height is 2 lines.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<textarea rows="positive-integer"></textarea>

rows specifies how many lines a textarea displays, not a limit on lines of entered text.

A supplied value must be a valid non-negative integer greater than zero. When the attribute is absent, parsing fails, or the result is zero, the character height is 2.

The DOM property rows reflects the attribute with a fallback of 2. The example reads 4, removes the attribute, and reads 2; the final field therefore has a character height of two lines.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>rows example</title>
<label for="notes">Notes</label>
<textarea id="notes" rows="4"></textarea>
<pre id="result"></pre>
<script>
  const notes = document.getElementById('notes');
  const values = [notes.rows];
  notes.removeAttribute('rows');
  values.push(notes.rows);
  document.getElementById('result').textContent = values.join('\n');
</script>
</html>

Result

4
2

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources