My code is as follows:
<div id="latest-text">
<p id="text-wrapper">
<span style="display: inline-block;" id="title">ABFDFDFJEKJRKEREJRKE</span>
<span style="display: inline-block;" id="subtitle">GJKJGKEJKEJFKAJKEJRE</span>
</p>
</div>
I want to make the width of the #text-wrapper element the larger width of #title or #subtitle element, but it seems that its width is always the same as the #latest-text element. Is there any way to achieve my goal?
Yes you can do that. Set one of the spans to block, and the parent p tag to inline-block. Let the second span be inline.
css:
See Dabblet: http://dabblet.com/gist/4694336