David G
David G

Reputation: 96845

How do I make it so that the width of a div compensates for the content inside of it?

I have a list inside a div with text of varying lengths. How do I make the div's width hold all of that content. I've tried width: auto (without actually knowing what would happen), but the div stretched out to the left of the window. Is there a property with which I can use to accomplish this?

Upvotes: 0

Views: 40

Answers (1)

James Montagne
James Montagne

Reputation: 78710

If I'm understanding you correctly, you can use display: inline-block;

http://jsfiddle.net/H66TB/1/

I'm taking you to mean that you want it to stretch to the content and not just go all the way to the end of the screen.

Upvotes: 1

Related Questions