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

TextArea Cols or Width?

P: n/a
Hello,

I am defining a Text Area where I set it to 20 Rows and Width of 40em
in my CSS code.

Do I need to define the cols?

In this case what is the difference between cols and width?

I suppose I cannot define the cols in CSS.

Thanks,
Miguel
Sep 3 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
On 2008-09-03, shapper <md*****@gmail.comwrote:
Hello,

I am defining a Text Area where I set it to 20 Rows and Width of 40em
in my CSS code.

Do I need to define the cols?
No, but you can-- then people who aren't using CSS will get what you set
for cols instead of the 40em.
In this case what is the difference between cols and width?
Cols is supposed to give you the width of an "average" character. Width
sets a width in one of the usual CSS units (which don't include "width
of average character").

If you set both, the CSS width wins in most browsers.
I suppose I cannot define the cols in CSS.
Correct.
Sep 3 '08 #2

P: n/a

Ben C wrote:
On 2008-09-03, shapper <md*****@gmail.comwrote:
>>
I am defining a Text Area where I set it to 20 Rows and Width of 40em
in my CSS code.

Do I need to define the cols?

No, but you can
http://www.w3.org/TR/html401/interac...#edef-TEXTAREA

Note the required fields.

--
Berg
Sep 3 '08 #3

P: n/a
On Sep 3, 3:56*pm, Bergamot <berga...@visi.comwrote:
Ben C wrote:
On 2008-09-03, shapper <mdmo...@gmail.comwrote:
I am defining a Text Area where I set it to 20 Rows and Width of 40em
in my CSS code.
Do I need to define the cols?
No, but you can

http://www.w3.org/TR/html401/interac...#edef-TEXTAREA

Note the required fields.

--
Berg
Yes, I knew that but somehow without cols I got my HTML validated ...
even If I had the opposite before
Sep 3 '08 #4

P: n/a
On Sep 3, 3:10*pm, Ben C <spams...@spam.eggswrote:
On 2008-09-03, shapper <mdmo...@gmail.comwrote:
Hello,
I am defining a Text Area where I set it to 20 Rows and Width of 40em
in my CSS code.
Do I need to define the cols?

No, but you can-- then people who aren't using CSS will get what you set
for cols instead of the 40em.
In this case what is the difference between cols and width?

Cols is supposed to give you the width of an "average" character. Width
sets a width in one of the usual CSS units (which don't include "width
of average character").

If you set both, the CSS width wins in most browsers.
I suppose I cannot define the cols in CSS.

Correct.
If the TextArea has, let's say 100 columns, and is inside a DIV of
50px width will the Text Area expand the width?

Thanks,
Miguel
Sep 3 '08 #5

P: n/a
On 2008-09-03, Bergamot <be******@visi.comwrote:
>
Ben C wrote:
>On 2008-09-03, shapper <md*****@gmail.comwrote:
>>>
I am defining a Text Area where I set it to 20 Rows and Width of 40em
in my CSS code.

Do I need to define the cols?

No, but you can

http://www.w3.org/TR/html401/interac...#edef-TEXTAREA

Note the required fields.
I stand corrected.
Sep 3 '08 #6

P: n/a
On 2008-09-03, shapper <md*****@gmail.comwrote:
On Sep 3, 3:10*pm, Ben C <spams...@spam.eggswrote:
>On 2008-09-03, shapper <mdmo...@gmail.comwrote:
Hello,
I am defining a Text Area where I set it to 20 Rows and Width of 40em
in my CSS code.
Do I need to define the cols?

No, but you can-- then people who aren't using CSS will get what you set
for cols instead of the 40em.
In this case what is the difference between cols and width?

Cols is supposed to give you the width of an "average" character. Width
sets a width in one of the usual CSS units (which don't include "width
of average character").

If you set both, the CSS width wins in most browsers.
I suppose I cannot define the cols in CSS.

Correct.

If the TextArea has, let's say 100 columns, and is inside a DIV of
50px width will the Text Area expand the width?
No, it will just overflow the div (unless you set display: table-cell on
the div).

If you set width: 50px on a normal block, you get 50px regardless of the
contents or of whether that's enough.
Sep 3 '08 #7

P: n/a

shapper wrote:
On Sep 3, 3:56 pm, Bergamot <berga...@visi.comwrote:
>>
http://www.w3.org/TR/html401/interac...#edef-TEXTAREA

Note the required fields.

Yes, I knew that but somehow without cols I got my HTML validated ...
The W3C validator gives an error when cols is omitted. e.g.

Error: required attribute "COLS" not specified .
<textarea name="x" rows="20"></textarea>

--
Berg
Sep 3 '08 #8

P: n/a
On Sep 3, 6:10*pm, Bergamot <berga...@visi.comwrote:
shapper wrote:
On Sep 3, 3:56 pm, Bergamot <berga...@visi.comwrote:
>http://www.w3.org/TR/html401/interac...#edef-TEXTAREA
Note the required fields.
Yes, I knew that but somehow without cols I got my HTML validated ...

The W3C validator gives an error when cols is omitted. e.g.

Error: required attribute "COLS" not specified .
<textarea name="x" rows="20"></textarea>

--
Berg
You are right ...

Hmmm, it got validated because my MVC framework or TinyMCE, which I am
using, adds cols and rows with default values 20 and 2.

That's why ...
Sep 3 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.