View Full Version : Textarea, Overflow and Max-Height

10-22-2006, 04:45 AM
hey, thanks in adavnce for any input!


I want the textareas to adjust to the size of the content here. Like if its one line, it should be 1 line, if its a few lines, be a few lines, unless its like 20 lines, I want it to overflow:auto.

I would think this can be done with max-height:10em and overflow:auto,
but it doesnt seem to be working. I think this may be because they are textareas which require the cols and rows attributes and already do some sort of overflow handling? is this true?

The only reason I'm using textarea elements is because I want to be able to have the JS onclick event select all the text in the element, and i couldnt get it to work with a pre tag. Perhaps this is my flaw and it is possible to select all onclick in a pre?

thanks again!

10-22-2006, 08:49 PM
Sounds like you need overflow: visible, but it doesnít seem to work on textarea elements.

Do you need all of the text to be selected so that it can be copied or just for the visual effect? If it's just for the visual effect, using text boxes for that purpose is unnecessary.

10-23-2006, 12:14 AM
the functionality of the 'select all' is to facilitate the copying of the snippets. Its not just for effect.

So i take it i am correct in finding that you can only have JS select the contents of inputs and textboxes? not things like pre? Honestly I'd rather use something like a pre, being as it could validate without the rows and cols attributes which are just more crap to type.

10-25-2006, 01:19 AM
So far as I know, that is correct. I wasnít even aware that you could select text using JavaScript though so maybe thereís a solution that Iím not aware of.

By the way, Iím of the opinion that the col and row elements should be deprecated since the size of a textarea element is generally defined by CSS and the attributes seem presentational. Not sure why theyíre still required.

10-25-2006, 09:21 AM
I think the rows and cols attribs might still be required because it's effects should provide the functionality to the form elements even even when there is no css. As in to ensure accessability, the size of the textarea should be defined reguardless of the media type? I really dont know about this, tho.

Any other ideas on how to fix my little conundrum?
(I guess maybe i should explore som JS solutions?)

lemme kno, and thanks in advance for any input!

10-25-2006, 04:45 PM
Well, I donít believe that single line input boxes require dimensions to be specified and they seem to display fine without CSS so it just seems kind of odd. At any rate, if dimensions are going to be required on text boxes, it would seem to make more sense to have width and height attributes and allow rows and cols as units instead of attributes, that way pixels, ems, et cetera could be used (without CSS); yet another one of my disagreements with the standards.