Raúl Ferràs Raúl Ferràs - 10 months ago 52
CSS Question

Should I size a textarea with CSS width / height or HTML cols / rows attributes?

Every time I develop a new form that includes a

I have the following dilemma when I need to specify its dimensions:

Use CSS or use the
's attributes

What are the pros and cons of each method?

What are the semantics of using these attributes?

How is it usually done?


I recommend to use both. Rows and cols are required and useful if the client does not support CSS. But as a designer I overwrite them to get exactly the size I wish.

The recommended way to do it is via an external stylesheet e.g.

textarea {
    width: 300px;
    height: 150px;

Inline styling is not good practice (should not be used unless it is very minimal) e.g.

<textarea style="width: 300px; height: 150px;">