The code below is a simplified version of my site. On my site, the width of the image varies from page to page, and the text is about 100 words. This means that the paragraph stretches the DIV to be wider than the image. Using only CSS, is it possible to reduce the size of the DIV and paragraph to the width of the image?
Jsfiddle here
An example of what I am trying to describe here . Top is what I get, bottom is what I want.
HTML
<div> <img src="image.jpg" /> <p>Lorem ipsum dolor sit amet.</p> </div>
CSS
div { display: inline-block; }
html css
colindunn
source share