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?

Problem courtesy of: 0x499602D2


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

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.

Solution courtesy of: James Montagne


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.