Size for textarea without cols or rows

I want to specify the size of a text area that displays text but with only CSS, is this possible?

Example :

<textarea name="Data" id="Data"></textarea>

#Data {
      max-height : 400px;
      height : 60%;
      max-width : 630px;
      width : 95%;
}
LVL 2
Adesso21Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Diablo84Commented:
Thats the right idea but while max-height and max-width is supported by Mozilla/Firefox is it not by IE.

So you might be better off with a fixed pixel width and height, eg:

#Data {
     height: 400px;
     width: 630px;
}

This may be worth a read: http://www.svendtofte.com/code/max_width_in_ie/
0
COBOLdinosaurCommented:
Why do you want to put a square peg in a round hole.  The rows and cols attribute are the correct way to dimension texareas in every current standard including XHTML.

This is CSS overkill IMO.

The page starts with HTML.  You use the tags and attributes to define the the required structures and you use the attributes to support the function they must perform to work with the data.  You are short butchering a data container by mixing content and presentation.  Use CSS fot its intende purpose, presentation and layout management.  Don't misuse it by replacing the valid attributes of the tags that are sensitive to content.

If the rows and cols attribute were intended to be replace by CSS they would have been depreciated along with a lot of other legacy attributes that are unnecessary.

Cd&
0
GrandSchtroumpfCommented:
The cols and rows are mandatory in the html, but you can overwrite them with the CSS.

I think it's a good idea to use a percentage width, this way you can resize the textarea... just like the one i'm currently typing in.
Cols don't make much sense to me because they don't match the character width, especially when using variable-width fonts ;-).

I would use "rows" to specify the height.
Using rows allow you to specify the number of lines that will be visible (no matter what font and font-size you use).
This makes more sense than specifying a pixel or percentage size.

So, this is what i would use:


<textarea name="Data" id="Data" rows='15' cols='48'></textarea>
#Data {
     width : 95%;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Adesso21Author Commented:
Thaks  GrandSchtroumpf

I managed to get the textarea to display like I want using the suggestions you made. It seems that the cols and rows are going to be around for a while then I guess..

The reason why I wanted to do this was I have a generic template that edit objects in a DB. I wanted the text area to grow depending on the actual content from the DB, but it seems that that dream has been demolished by reality.

I'll play some more with the styles and HTML and post the final conclusion I get to here.. thanks for the input guys.
0
Adesso21Author Commented:
<style>
TEXTAREA {
      max-height : 400px;
      height : 90%;
      max-width : 630px;
      width : 95%;
}
</style>

<textarea name="Data" id="Data" cols="64" rows="12"></textarea>

That is the best I could get it. Seeing that I can manupulate the surrounding tags I can rewrite the actual display of the text area even if I told it that it should be 64 cols and 12 rows .. just wrap it in a table and resize with a class or id selector.

As  Cd& said "This is CSS overkill IMO."

I tend to agree. With no styles in some weird case the data still retains a usable disply size.



0
GrandSchtroumpfCommented:
thanks for the points
<:°)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.