tags:

views:

35

answers:

1

Given a DIV with a fixed width, is there a way to have it use as much vertical space as it needs by wrapping the content (which is plain text)? The CSS "overflow" property provides for scrollbars (overflow:scroll) and chopping content (overflow:hidden) but that's not what I want.

Help? Thanks

+2  A: 

Yeah. Just leave it alone. It will resize to the content vertically just fine. Your page might get a scrollbar, though.

Robusto
Make sure you've removed any explicit height that you may have set, too. You will want a height of "auto," the default.
ajm
Nope, it doesn't work. With only "width:300px" set, the content overflows the div instead of wrapping. The DIV is in a TD, does that make a difference?
VANJ
@VANJ: Uh, yeah, that can make a difference. Why don't you post a link or some code?
Robusto
@Robusto - Yikes, there was a TD somewhere in the markup with "nowrap" set. Getting rid of that and adding "white-space:normal" to the DIV did what I wanted. Thanks!
VANJ