Raúl Ferràs Raúl Ferràs - 3 months ago 12
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

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

Use CSS or use the
textarea
's attributes
cols
and
rows
?

What are the pros and cons of each method?

What are the semantics of using these attributes?

How is it usually done?

Answer

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;"> 
Comments