I need my text wrapper width to automatically shrink below an image.
For instance:
<figure>
<img src="mypicture.jpg" />
<figcaption>
This is a lengthy description. This is a lengthy description. This is a lengthy description.
</figcaption>
</figure>
Currently, I want to include a border
around both the img
and figcaption
elements, as my images have varying widths. I would like the width of the figcaption
to adjust automatically to match the image's width. For example, if an image has a width of 100px, then the figcaption
should also be 100px.
Can anyone advise me on whether this can be achieved using only HTML and CSS, without JavaScript?