To display figures, I use
<figure>
<img …>
<figcaption>This is a longer caption that may wrap lines.</figcaption>
</figure>
Now I'm trying to get the following via CSS:
figureis horizontally centered on the page.figcaptionhas the same width asimg. This is important for line wraps.- The width comes from
img. figcaptionis left-aligned withimg.
In other words, what I want is this (boxes for clarity):
I have hacked the above mockup by giving figure an explicit width (i.e., violating 3 above), but of course that's not very desirable.
How do I get this to work? Should I look into layout: flex?
