By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

form examples in css2?

P: n/a
Hi,

I'm having problems with css2/xhtml based form. I didn't find examples
to see what can be done, especially textarea. How to define cols="45"
rows="4" in css?
Jul 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Franck wrote:
Hi,

I'm having problems with css2/xhtml based form. I didn't find examples
to see what can be done, especially textarea. How to define cols="45"
rows="4" in css?


You can't define.
Number of columns and rows is part of functionality definition of form
elements, not a layout definition.

--
Janusz 'Kali' Kaliszczak
=> http://janusz.kaliszczak.pl/
Jul 21 '05 #2

P: n/a
On Thu, 27 Jan 2005 11:40:12 +0100, Franck <fl****************@free.fr>
wrote:
Hi,

I'm having problems with css2/xhtml based form. I didn't find examples
to see what can be done, especially textarea. How to define cols="45"
rows="4" in css?


Salut Franck! Voilą:
http://www.quirksmode.org/css/forms.html

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Discover Opera: http://members.surfeu.fi/jerkku/
http://www.auriance.com - http://www.auriance.net
Jul 21 '05 #3

P: n/a
Franck <fl****************@free.fr> wrote:
I'm having problems with css2/xhtml based form. I didn't find examples
to see what can be done, especially textarea. How to define cols="45"
rows="4" in css?


You can set the width and height for the textarea just the same as for
any other element. But you must still include the cols and rows in the
HTML as those attributes are required by the HTML specification.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 21 '05 #4

P: n/a
Steve Pugh wrote:

You can set the width and height for the textarea just the same as for
any other element. But you must still include the cols and rows in the
HTML as those attributes are required by the HTML specification.


This is a genuine query.

Why "must" one include the cols and rows attributes if height and width
are declared by a css rule set. Is it just to satisfy the validator?

"The required ROWS and COLS attributes specify the number of visible
rows and columns, respectively, in a visual browser. These attributes
provide a <<guide>> for the user rather than a restriction; browsers
allow an unlimited amount of text input in theory, though in practice
many browsers limit the contents of a TEXTAREA to 32 or 64 kilobytes".

The css properties WIDTH and ROW seem to provide the same <<guide>> and
moreover seem to over ride the HTML attributes. Do I miss something?

Louise
Jul 21 '05 #5

P: n/a
You can set the width and height for the textarea just the same as for
any other element. But you must still include the cols and rows in the
HTML as those attributes are required by the HTML specification.


thanks guys, I got it!
Jul 21 '05 #6

P: n/a
boclair <bo*****@boclair.com> wrote:
Steve Pugh wrote:
You can set the width and height for the textarea just the same as for
any other element. But you must still include the cols and rows in the
HTML as those attributes are required by the HTML specification.
This is a genuine query.

Why "must" one include the cols and rows attributes if height and width
are declared by a css rule set. Is it just to satisfy the validator?


It's not just the satisfy the validator - the validator requires it
because the spec requires it. Not the other way round.

But why does the spec require it is a good question. I'm not sure I
have a complete answer.
"The required ROWS and COLS attributes specify the number of visible
rows and columns, respectively, in a visual browser. These attributes
provide a <<guide>> for the user rather than a restriction; browsers
allow an unlimited amount of text input in theory, though in practice
many browsers limit the contents of a TEXTAREA to 32 or 64 kilobytes".
It's interesting that the mention of them being a 'guide' is in the
same sentence as the mention of a limit on the size of the data
accepted. A smart author can pick col and row values that give users a
guide as to how much data is expected from them. As such it would not
be unreasonable for non-visual user agents to indicate this 'size' in
some way.
The css properties WIDTH and ROW seem to provide the same <<guide>> and
moreover seem to over ride the HTML attributes. Do I miss something?


The row and col values are (loosely) tied to the size of a character
and thus fit well with the "expected amount of data" idea. The CSS
length units can be (loosely) tied to the size of a character (em and
ex) or totally divorced from it (px, mm, %, etc.) so the two are not
interchangable.

In practical rather than theoretical terms you should start by
recalling that CSS is optional. Some browsers have very silly default
sizes for textareas and specifying a sensible fallback for when CSS is
not enabled (or is being ignored, e.g. Opera has an option to disable
styling of just form elements) is smart.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 21 '05 #7

P: n/a
Steve Pugh <st***@pugh.net> wrote:
But why does the spec require it is a good question. I'm not sure I
have a complete answer.
Neither do I, especially since the HTML spec does not require a SIZE
attribute in <input> elements but implies some browser-specific default
(though the situation is different, since not all <input> elements are text
input fields). My answer is that there is no good answer. Someone just
decided that ROWS and COLS are required, instead of deciding that browsers
are expected to use some defaults. (They were required even in HTML 2.0.)
"The required ROWS and COLS attributes specify the number of visible
rows and columns, respectively, in a visual browser. These attributes
provide a <<guide>> for the user rather than a restriction; browsers
allow an unlimited amount of text input in theory, though in practice
many browsers limit the contents of a TEXTAREA to 32 or 64 kilobytes".


It's interesting that the mention of them being a 'guide' is in the
same sentence as the mention of a limit on the size of the data
accepted.


The text was quoted without specifying the source. It is apparently from
the WDG HTML 4.0 reference, which is excellent, but not a specification:
http://www.htmlhelp.com/reference/ht.../textarea.html
The specification
http://www.w3.org/TR/html4/interact/...#edef-TEXTAREA
defines ROWS as specifying the number of rows and COLS as specifying "the
visible width in average character widths". So they are specific
instructions to browsers rather than a guide. Quite independently of this,
browsers are expected to allow unlimited input, i.e. the numbers are not
limits upon amount of data but dimensions of physical input area.
A smart author can pick col and row values that give users a
guide as to how much data is expected from them. As such it would not
be unreasonable for non-visual user agents to indicate this 'size' in
some way.
Or maybe it would. In practice at least. It is horrendously common to
specify ridiculously small ROWS and COLS attributes. I guess the resulting
stamp size honestly reflects the value assigned to user input by the form
designer. But I still would not suggest that non-visual user agents tell
some guesses based on those values. After all, if the user input has some
maximum or recommended size, then it's the form designer's job to tell them
in the textual content before the field.
The css properties WIDTH and ROW seem to provide the same <<guide>> and
moreover seem to over ride the HTML attributes. Do I miss something?


The row and col values are (loosely) tied to the size of a character
and thus fit well with the "expected amount of data" idea.


Technically, they are related to text line height and average character
width.
The CSS
length units can be (loosely) tied to the size of a character (em and
ex) or totally divorced from it (px, mm, %, etc.) so the two are not
interchangable.
In practice, ROWS and COLS are often the _best_ way to specify the
dimension. They have no direct CSS counterpart. But if you explicitly set
line-height, then ROWS="n" should be equivalent to height: n2, where n2 is
n multiplied by the line-height value. But this is not very relevant, since
the ROWS attribute is required. For COLS, there is really no CSS
equivalent; there is no concept like "average character width" in CSS.
As a rough rule of thumb, em corresponds to two times the average character
width and ex corresponds to the average character width. But this is just
the average over fonts. In most fonts, it's either bigger or smaller.
In practical rather than theoretical terms you should start by
recalling that CSS is optional. Some browsers have very silly default
sizes for textareas - -


Or they may have no defaults. A textarea without those attributes is a
syntax error, and browsers may do whatever they like, e.g. not render the
textarea at all.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 21 '05 #8

P: n/a
"Jukka K. Korpela" <jk******@cs.tut.fi> wrote:
Steve Pugh <st***@pugh.net> wrote:
But why does the spec require it is a good question. I'm not sure I
have a complete answer.
Neither do I,


Oh good, that probably means I didn't miss anything obvious.
My answer is that there is no good answer. Someone just
decided that ROWS and COLS are required, instead of deciding that browsers
are expected to use some defaults. (They were required even in HTML 2.0.)
And, unlike in some other cases, HTML 2.0 doesn't provide a clearer
rationale over that (not) given in HTML 4.01 :-(
"The required ROWS and COLS attributes specify the number of visible
rows and columns, respectively, in a visual browser. These attributes
provide a <<guide>> for the user rather than a restriction; browsers
allow an unlimited amount of text input in theory, though in practice
many browsers limit the contents of a TEXTAREA to 32 or 64 kilobytes".


It's interesting that the mention of them being a 'guide' is in the
same sentence as the mention of a limit on the size of the data
accepted.


The text was quoted without specifying the source. It is apparently from
the WDG HTML 4.0 reference, which is excellent, but not a specification:
http://www.htmlhelp.com/reference/ht.../textarea.html


Oh, well, in that case my little thought experiment is a bit of a
waste of time. Never mind.
browsers are expected to allow unlimited input, i.e. the numbers are not
limits upon amount of data but dimensions of physical input area.


Oh yes. I never meant to imply otherwise.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.