473,756 Members | 3,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<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 31447
Gazing into my crystal ball I observed Tony
<to****@dslextr eme.WHATISTHIS. com> writing in
news:12******** *****@corp.supe rnews.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:10 0%;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:10 0%;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
4327
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: http://validator.w3.org/check?uri=http://www.stargazing.net/mas/COMET.htm In the <textarea> of this page I have Javascript code. I can't figure out how to present this code and still be w3c valid. Any advice would be appreciated...Dennis
16
2920
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 tag />, but selected everything after til the EOF as text within the textarea.
11
13722
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, there's an "Edit" link. So the page itself looks something like this: <HTML><HEAD><TITLE>blah</TITLE></HEAD><BODY> <!-- TEXT STARTS HERE --> <H1>Hello World!</H1> <P>More stuff here...</P>
3
6784
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 field. How to do this? regards jaro
4
2233
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 portable and elegant if anybody could do. It will be of great help. Also I would like to add mincount ie: a text less than mincount should raise error ----------------------
3
5670
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 replace spaces with &nbsp;. The <br> part works well enough, but I keep getting "%20" instead of "&nbsp;" for the spaces. I understand that escape() changes " " to "%20", but I would think the ConvertSpaces function below would change the %20 to...
7
3112
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) or to complex solutions that work on top of specific frameworks. Do you have some reference on how to do it? I'd like to make it work in at least Firefox and IE 6 and 7. Thank you in advance,
3
11758
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 reason to avoid it? Thanks in advance! Bugboy
2
16109
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?
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9843
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.