Reputation: 52047
What's the difference between sizing a textarea with cols and rows and sizing a textarea with height and width?
<textarea id="TextArea1" cols="73" rows="12">with cols rows</textarea>
<textarea id="TextArea2" style="height:200px; width:600px";>with CSS</textarea>
Upvotes: 15
Views: 48206
Reputation: 201866
cols
and rows
attributes were required by HTML specifications. W3C HTML5 (approved in 2014) made them optional, but with impractical default values (20 and 2).rows
attribute specifies the height in terms of lines (effectively, with the line height as implied unit), and the cols
attribute specifies the width in terms of “average” character width, a very vague concept, interpreted very differently by browsers. In CSS, any CSS units can be used and must be explicitly specified.Upvotes: 5
Reputation: 78740
cols
and rows
are relative to font size. height
and width
aren't.
EDIT: Saying they are relative to "font size" is a bit too simplistic. They take into account things such as line-height
and letter-spacing
if explicitly set as well.
Upvotes: 14
Reputation: 128
CSS isn't that different. The result will be (almost) the same.
I'm using most of the time max-width, min-width and the same for height. In new browsers like Chrome you can resize the textarea.
Upvotes: 0