The code below is a simplified version of my website. On my site, the image width varies from page to page and the text is around 100 words. That means the paragraph stretches the DIV to be wider than the image. Using only CSS, is it possible to shrink the DIV and the paragraph to the width of the image?
Example of what I'm trying to describe here. Top is what I'm getting, bottom is what I want.
HTML
<div>
<img src="image.jpg" />
<p>Lorem ipsum dolor sit amet.</p>
</div>
CSS
div {
display: inline-block;
}
See Question&Answers more detail:os