Take the 2-minute tour ×

The "cols" attribute is required in valid HTML but I don't see the benefit of using it. Do you?

share|improve this question

5 Answers 5

up vote 2 down vote accepted

If the client does not support CSS, it will still be able to see <textarea> with right width.

share|improve this answer
Are there clients that do not CSS and if the <textarea> requires a "cols" attribute, why the <input type="text"> does not? –  Emanuil Rusev Aug 3 '10 at 11:47
Because it has other attributes: <input type="text" size="10" maxlength="20"> See also: w3.org/TR/html4/interact/forms.html#h-17.4 –  Denilson Sá Aug 3 '10 at 11:54
@Denilson — but they aren't mandatory. –  Quentin Aug 3 '10 at 11:58
Because it only makes sense for text and password types, and the <input> element is also used for radio, checkbox, button... Also remember the spec was made to officialize the behavior already common among existing browsers. It doesn't need to make perfect sense. –  Denilson Sá Aug 3 '10 at 12:04
@Emanuil. Lynx does not support CSS for example. The HTML specification does not give any answers on your quiestion. It just says, "cols and rows are required". I think they are required as fallback if browser doesn't support CSS, or if user disabled it; it's reasonable. Also CSS width/height and cols/rows act differently. –  fuwaneko Aug 3 '10 at 12:06

It determines how wide to render the element.

share|improve this answer
Yes, but you can do the same through CSS and do it much more precisely. –  Emanuil Rusev Aug 3 '10 at 11:44
The spec predates common CSS support and use (and given a monospace font (the default), columns is usually a much easier way to get the precise width you want) –  Quentin Aug 3 '10 at 11:46

"cols" using for increase the width of textarea` in html.

share|improve this answer

When browsers and html parsing software looks at HTML it will be looking for a set of mandatory attributes on a tag. Such as every <img> tag needs an alt="" attribute.

So when running your site through a HTML validator you need to make sure the mandatory attributes are in place else validation will fail..

Secondly when a user is using assistive technologies, they tend to turn off CSS/Javascript altogether so making sure you have cols="" in there is important. Screan readers and such may not be able to parse your webpage properly if it can't find required attributes for your markup.

Conclusion: Theres a bigger picture than just tweaking some stylesheet info. Make sure you conform to spec. If you want to style things pretty make sure you have sensible fallback for non-css webpages.

share|improve this answer

Your Answer


