What is the unit of the "rows" and "cols" attribute values in a "textarea" tag?

When creating a “textarea” tag, what is the unit of the “rows” and “cols” attribute values and what determines the actual physical size of the field?

https://www.codecademy.com/paths/web-development/tracks/learn-html-web-dev-path/modules/learn-html-forms/lessons/html-forms/exercises/textarea-element

The <textarea> element rows attribute has a unit equal to one row of text, and the cols attribute unit is equal to the average area taken up by one character.

<textarea rows="3" cols="15">

This will display a text field that shows about 3 rows of 15 characters.

Its actual physical size is relative to your font size. A <textarea> styled to have font-size: 50px; will be much larger than a <textarea> styled to have font-sixe: 20px;

I recommend checking out the documentation at a website like MDN
developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea

2 Likes

Awesome explanation. Very much appreciated.

1 Like