I am working with a RichText editor and I am trying to allow users to create their own custom figcaption
for a figure. The challenge is that the figure number must be generated separately. I want to merge the user's description of the figure (p
tag) with the number (span
tag) to make them appear as a single cohesive paragraph
. I attempted to use float: left
on the span
, but I am struggling to center it correctly (the combined figcaption
should span the width of the entire page rather than just the width of the image).
Check out my demo: https://codepen.io/degel123/pen/rNRpWNQ
As you can see, the float
element is not centering properly. I attempted to add
width: fit-content;
margin-left:auto;
margin-right:auto;
to the figcaption
style, but then the content splits into two lines instead of remaining on one line.