tags:

views:

62

answers:

5

Every time I develop a new form that includes a textarea I have the following dilemma when I need give its dimensions:

Go through CSS path or use their attributes col and rows?

What pros and cons can I found using both paths?

What semantic information gives using these attributes?

How people usually does it?

+1  A: 

According to the w3c, cols and rows are both required attributes for textareas. Rows and Cols are the number of characters that are going to fit in the textarea rather than pixes or some other potentially arbitrary value. Go with the rows/cols.

tandu
+2  A: 

I recommend to use both. Rows and cols are requrired and useful if the client does not support CSS. But as a designer I overwrite them to get exactly the size I wish (not to mention you don't do this inline via <textarea style="width: 300px; height: 150px;>, do it in an external stylesheet).

kogakure
This is okay, but you have to realize that whatever arbitrary space you are setting the size with is going to waste and is really just for show.
tandu
@tandu: What do you mean by "is going to waste and is really just for show"?
BoltClock
rows/cols is based on the character size of the user. So if you have a css-defined width/height that cannot be divided by the pixles of a character in the textarea, there is going to be that much whitepsace left over vertically and horizontally. Probably no one will ever notice, but just sayin.
tandu
You could use "em" as measurement, instead of pixels. 1em is the width of the "M" in any font and size. But cols are only relevant if used with monospace fonts, which is in most designs not the case. To get a perfect fitting in height use a multiple of `line-height` for the height of your textarea.
kogakure
+1  A: 

The answer is "yes". That is, you should use both. Without rows and cols (and there are default values even if you don't use them explicitly) the textarea is unusably small if CSS is disabled or overriden by a user stylesheet. Always keep accessibility concerns in mind. That being said, if your stylesheet is allowed to control the appearance of the textarea, you will generally wind up with something that looks a whole lot better, fits into the overall page design well, and that can resize to keep up with user input (within the limits of good taste, of course).

Stan Rogers
A: 
<textarea style="width: 300px; height: 150px;>
did you know how to use css?
+2  A: 

The size of a textarea can be specified by the cols and rows attributes, or even better; through CSS' height and width properties. The cols attribute is supported in all major browsers. One main difference is that is a container tag: it has a start tag ().

AsifQadri