| Depr. | Version |
|---|---|
| No | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
Description
The
rows attribute defines the number of lines of text
that are visible in the textarea. However, how well
this actually matches up to the number of characters displayed height-wise
is debatable, as the font style for characters may vary between
browsers—especially if the style is changed by CSS. If no
rows attribute is specified (even though it’s a
required attribute), the textarea will render
with approximately three visible lines of text. If you provide a
rows value of "10", the
textarea appears just over three times taller than the
default height, as Figure 1
shows.
textareas, the first without a
rows attribute, the second with
rows set to "10"
Note that rows is a required
attribute, as is cols, so you shouldn’t
replace it with CSS styling. Instead, the CSS should
override the size defined in this attribute. Without this
attribute, your page can’t possibly validate (and besides, it’s helpful
for users who are browsing with CSS switched off).
Example
The rows
attribute for this textarea is set to
"10":
<form> <label for="perfectday">Describe your perfect day:</label> <textarea id="perfectday" accesskey="d" cols="40" rows="10"> </textarea> <input type="submit" value="Tell us"/> </form>
Value
This attribute accepts a number only—it won’t accept percentages or other values.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
It causes no compatibility issues, and has excellent support across all tested browsers.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.