2

So I have a parent HTML element with 2 children.

<div id="parent">
    <div id='title"></div>
    <div id="body"></div>
</div>

I want the parent to expand the width to fit the #title, but the #body to line wrap:

[Title]
-------
|This |
|is   |
|body |
|text | 

The idea being if the #title is longer, the #body line wraps later:

[Longer Title]
--------------
|This is     |
|body text   |

I'm curious if this is do-able in pure CSS. Specifically, when I google for something about children not expanding parents or parents only expanding for certain children I don't get anything.

Bonus part: This might be javascript territory, but I'm also curious if there is a way to set a min-width on the #body if and only if the text is long enough to warrant one.

James
  • 2,660
  • 17
  • 37

0 Answers0