Best way to have div width grow with content?

Divs by default take up the entire span of the browser window. I just want it to take up the width of the contained content. What’s the best way to do this. I’ve seen using display:table, but it doesn’t work in IE7.

What is the proper method for this?

Thanks, Paul

Thanks for the reference! Bookmarked!

Paul

I’ve seen using display:table, but it doesn’t work in IE7.
What is the proper method for this?

Hi,
Your on the right track, display:table is the best way to go for that. IE6/7 are best controlled with a small bit of js.

I gave some info about it in this recent thread.

When using display:table it will treat width as if it were min-width, basic table behavior. By doing that any other block level children with width:auto; (such as a <p> tag) will not force the parent to fill the viewports available space. If there is a block child with a defined width greater than the parent’s width it will expand to accommodate it. (kinda like IE6 does)

Here are some examples I put together a while back.