473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

<textarea> cols & rows

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)
May 10 '06 #1
6 31402
Gazing into my crystal ball I observed Tony
<to****@dslextreme.WHATISTHIS.com> writing in
news:12*************@corp.supernews.com:
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)


If CSS is not available there could be issues. For example, if your
textarea is quite large, say 300px x 300px, without styling, the widget
is very small causing the user to have to scroll a lot.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

May 11 '06 #2
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.
So, surprisingly, the w3schools site hasn't messed up this simple thing.
It is generally useless as a _reference_, no matter what one might think
about the _pedagogical_ suitability of some material there. Personally,
I'd prefer learning things from a source that has got them mostly right,
even if some other source might present them more reasably.
What I'm wondering is - 'cols' & 'rows' determines the height & width of
a textarea.
The visible height and width, yes, though not quite consistently. I just
noticed that IE 7 beta uses an area that is 19 characters wide when
using the default (monospace) font there, when I set cols="19". Maybe
this is so because the vertical scroll bar occupies roughly the width of
one character.
So shouldn't that be something that is handled by CSS
instead?
In some other universe, perhaps. This is not pure presentation, however.
The visible size of the field conveys a message about the amount of
expected typical input (so that authors can use a stamp-size textarea in
feedback forms to express how much feedback they want :-) ). There is no
way in HTML to express the kind of expected input (say, an address, a
short letter, or a novel), so the rows and cols attributes work as
(very) implicit indicators.
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)


Perhaps it "works" for some value of "works". Have you tried it in all
browsers with all settings? Remember that HTML specifications do not
mandate the processing of invalid documents, so you cannot blame anyone
but yourself if Mozilla 2.0 or IE 8.0 decides to ignore <textarea>
elements without the required attributes.

What happens in practice at least in most browsing situations is that
browsers use some default values. IE 7 beta seems to use rows="2"
cols="20". This is a strong reason for not omitting the attributes: the
effect is generally browser-dependent and typically a quite small
textarea, with dimensions that are hardly suitable for anything that you
could meaningfully use <textarea> for.

You do realize, don't you, that CSS is for optional presentational
suggestions? When CSS is disabled, or even unsupported by a browser, the
dimensions of <textarea> are determined by the rows and cols attributes
(or their browser-dependent default values).
May 11 '06 #3
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.

May 12 '06 #4
I'm an absolute novice when it comes to CSS, but I was very pleased to
find that it could be used to make a textarea scale to fit the width of
the browser window:

<TEXTAREA NAME=SAYING WRAP=VIRTUAL style="width:100%;height:180"></TEXTAREA>

Up until I discovered this I was always bothered by the fact that I
either had horizontal scrollbars or wasted space on the right side of
the page.

The HTML above, by the way, was intended only for my own use. In the
page where it occurs, I'm the only person who gets this particular input
area.
--
Steve Swift
http://www.ringers.org.uk
May 18 '06 #5
Steve Swift <St*********@uk.ibm.com> scripsit:
<TEXTAREA NAME=SAYING WRAP=VIRTUAL
style="width:100%;height:180"></TEXTAREA>


Conforming browsers ignore the declaration height:180, since its value is
syntactically incorrect. You probably meant height:180px, but you should
actually use something more flexible such as height:15em.

(This is actually a stylesheet matter, not about HTML.)
May 18 '06 #6
> you should actually use something more flexible such as height:15em.

Thank you for that correction.

--
Steve Swift
http://www.ringers.org.uk
May 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dennis Allen | last post by:
Hi. I hope someone here can help. I'm webmaster for a local astronomy club. Just went over our web site. Have validated every htm file on the site except:...
16
by: Martin Trautmann | last post by:
Hi all, I just had a problem where Mozilla 1.6 did not accept a XHTML 1.0 page that contained <p><textarea cols="50" name="prod_prob_description" rows="4" /></p> It did not accept the end...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
3
by: Jarek Mielcarek | last post by:
hi all, in xml file I have some fields which are source for <textarea> element. I'd like to transform this file using xslt and set the rows property of <textarea> depend of lines in some source...
4
by: princeofcode | last post by:
Hey all, The following function counts for number of characters in a text area and displays error msg when it exceeds a maximum limit I would like to optimize this function so that its highly...
3
by: FunkHouse9 | last post by:
I'm working on a form to collect data in a textarea which and am trying to keep returns and spaces. I have a couple of functions that I Frankensteined together to replace returns with <br> and to...
7
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
I need to emulate the missing "maxlegth" attribute in "textarea" fields but all my Google searches either lead to obsolete scripts that overwrite the "value" property (thus losing caret position)...
3
bugboy
by: bugboy | last post by:
Is it ok to use CSS height: and width: attributes instead of rows and cols to size a textarea? It seems to work but i think i remember reading somewhere that i shouldn't do it...Is there any good...
2
Prakash Gnana
by: Prakash Gnana | last post by:
<textarea name="quest" id="quest" value='gggg' rows="10" cols="100"></textarea> I cannot set the value for textarea. Can you please help me to set value for it?
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.