Tony wrote:
The w3schools HTML tag reference for <textarea>
http://www.w3schools.com/tags/tag_textarea.asp
says that the attributes 'cols' and 'rows' are REQUIRED attributes for
the textarea tag. Looking at the HTML 4.01 specification I see this, too.
What I'm wondering is - 'cols' & 'rows' determines the height & width of
a textarea. So shouldn't that be something that is handled by CSS
instead? What would be the practical consequence of leaving out both
attributes and setting the height & width with CSS (I know it works -
I've tried it, but I'm wondering if there might be something I'm missing)
Considering the utility of textarea, it's rather an unloved creature,
without a real sense of belonging. When the web was first developed,
telnet and email were almost an afterthought. And yet they became
a primary underpinning of the web - people at the time didn't realize
how compelling the communication aspect was. Similarly with
textareas, which were intended to be used strictly to get some input
from the user. Thus, the logic saying that content of a textarea
is not considered part of its innerHTML, seems, in retrospect, not
so very clever.
So the thing about cols is that it serves a dual purpose. The
first is that rows and cols are a default way to specify the size of
the textarea, but that is overridden by CSS. Frankly, requiring cols
and rows is another silly thing which requirement may finally be
obsoleted:
http://www.whatwg.org/specs/web-form...k/#extensions1
For the second purpose, consider a chunk of text plopped into a
textarea. It may be that what is important (from the web page's
point of view) is the original/intended formatting of the text,
regardless of what viewing limitations the textarea imposes, or
it may be that what is important is the way the user actually
sees what is in the textarea.
For example, if the text started out as:
The quick brown fox jumped over the lazy dog.
and the user sees, in the textarea:
The quick brown fox
jumped over the lazy
dog
what should be submitted to the server?
To accommodate this the textarea takes the settings
wap=soft (default) or wrap=hard. If the textarea has
wrap=soft set, then what is submitted reflects the underlying
text whereas with wrap=hard the server gets the a string
corresponding to the viewed text. And this is reasonable.
But then the proposal above becomes completely
silly saying that cols is to used in determining where to
add the inserted newlines. In other words, rather than
submitting what the user sees, or what the underlying
text is, a third version that is not related to either of these
is submitted. And the worst part about that is that
it could just as well be (indeed, should be) determined
on the server. There is no architectural reason that I
can see for having it client side - it serves no purpose,
and imposes client side computation for something that
is server side responsibility (someone could easily alter
the .wrap on the submitting textarea, for example)
Fortunately, the proposed new spec is not totally lame on
this point. It begrudgingly says that if you don't specify
cols with wrap=hard, then the actual (observed) wrapping
should be used (But then it says that that would be
silly and defeat the purpose of client-side wrapping,
without mentioning what that purpose is).
Unfortunately, in the current implementation of Firefox,
if you don't specify cols when wrap is set to hard, then
you will get a default wrap at 20. The conclusion is that
if you have wrap=hard and use CSS to set the size of
the textarea, then the string submitted for the textarea
will probably not be well related to what the user enters.
Csaba Gabor from Vienna
Note 1: There is another wrap setting, to the tune of
wrap=off, but this is essentially syntactical sugar for
saying: wrap=soft and have horizontal scroll on overflow.
It doesn't change what gets submitted.
Note 2: Textareas fonts don't have to be fixed width.
In this case a well implemented textarea
element wraps when there isn't anymore room (as
opposed to at a fixed character count). I let you
figure out which browsers actually implement it well.