homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

Styling a <textarea>
Can you override rows and cols with CSS?

 7:39 am on Apr 16, 2003 (gmt 0)


is it possible to manipulate the <textarea>-tag, so that i can give it a width and a height instead of rows and cols?



 7:44 am on Apr 16, 2003 (gmt 0)


You can (at least in IE6 and the latest Mozilla), but I don't know where it stands as far as CSS standards / specifications are concerned.


 7:48 am on Apr 16, 2003 (gmt 0)

Yes just create a style like:
.textFormFields {width: 150px;} and assign it to all your form fields and they will neatly be aligned.

If you want to assign a height you will need to create another style otherwise your other form fields will have this height.

(I usually also assign font value because the textarea utilize a different type of font than the form fields)



 7:55 am on Apr 16, 2003 (gmt 0)

Just did a quick experiment;

It seems that the style attributes override rows and cols (as expected), so I would still include both to allow for graceful backward compatibility.


<textarea cols='20' rows='20' style='width:500px;height=500px;'>blah,blah,blah</textarea>

(or if you're using CSS apply the width and height via a class attribute of course)


 9:15 am on Apr 16, 2003 (gmt 0)

Thanks for our your answers.
I think this suits best in my situation


It seems rather simple, but i don't know if i could have figured that out. At least not in such a short time.
It works excellent in IE and Mozilla. In Opera the height is the height that is needed for the text between the textarea tags. So <textarea style='width:100%;height:100%;'>some text</textarea>, would make the textarea 1 row high.
I try to find a solution for that. If i'll find I'll post it here.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved