<div id="parent">
<div id="child">
content...
</div>
</div>
Is it possible to make #child as wide as the content is? Making it wider than #parent, which has a fixed width, if needed.
(in my case content is an unknown text string that I don’t want to line break)
You can set
display:inlineandwhite-space:nowrapon your#child, which will give you the results you’re desiring. The container will only be as wide as the content within, and will exceed the width of the parent if necessary.Demo: http://jsbin.com/ebuxup/edit#html,live