div.autosize { display: table; width: 1px; } div.autosize > div { display: table-cell; }
In your HTML, enclose the <DIV> you want autosized in another <DIV> with class="autosize"
Before:
<div> I want this to be auto sized! </div>
After:
<div class="autosize"> <div> I want this to be auto sized! </div> </div>
Tested in Firefox, Mozilla, Safari, Opera 7, and Internet Explorer 6.