How can I make a div not larger than its contents?

George Snider picture George Snider · Jan 16, 2009 · Viewed 1.5M times · Source

I have a layout similar to:

<div>
    <table>
    </table>
</div>

I would like for the div to only expand to as wide as my table becomes.

Answer

user473598 picture user473598 · Oct 12, 2010

The solution is to set your div to display: inline-block.