rows

The rows attribute in HTML sets the number of visible text lines in a <textarea>, determining its height for user input.

rows attribute

The rows attribute in HTML is used with the <textarea> element to define its visible height by specifying the number of visible text lines. This numerical value allows developers to adjust the text area's vertical size, catering to various uses, from short comment boxes to larger editing spaces.

Syntax

index.html
<textarea rows="number">

Example

index.html
<textarea rows="10" cols="50">This is a text area with 10 rows and 50 columns.</textarea>

Definition and Usage

The rows attribute defines the visible height of a textarea, measured in lines.

The size of a textarea can also be controlled using the CSS height and width properties.

Values

  • number
    • A value that defines the number of visible lines in a <textarea>.

Applies To

The rows attribute is applicable to the following HTML element:

Conclusion

The rows attribute in HTML controls the visible height of a <textarea> by specifying the number of text lines shown. It helps tailor the input area's size for different use cases. This attribute improves user experience by making text areas appropriately sized.