Trouble Formatting Caption Under Photo

I’m having a problem getting the caption formatting to stick under a photo in my ebook. I have the text styled with a caption style and have even used preserve text and it refuses to appear centered. I’ve been able to get it to appear indented and italicized, but can’t get it to appear center justified. I have adjustments in the css as follows…

.caption { margin: 3rem 3rem 3rem 3rem; text-indent: 0rem; text-align: center !important; font-style: italic; line-height: 1.2em; font-size: 0.83rem; }

and everything works except for the centering. As seen below…


Any help resolving this would be greatly appreciated.

Have you examined the HTML output in an ePub editor? I ask because by default if you use the “Caption” style in the editor, and you’re working from our built-in Ebook format as a starting point, then the default behaviour is to wire the “Caption” style to formal captioning in the HTML Elements format pane. The implication is that the output will use modern HTML5 elements for displaying a figure with a caption:

[code]

This is the text of the caption. This is the text of the caption. [/code]

As you can see, there is no element classed as “caption”, and so your selector would do nothing in this scenario. It is using the new element, and if you go over to the CSS format pane and search for figcaption in the “Default CSS” split, you’ll find settings base on however you styled things in the Styles pane.

Thus ultimately it may be as simple as setting centre-alignment in the Styles pane on the “Caption” style. But if you want to do a full override with your own CSS, you can of course use the figcaption selector to do so.

Granted you might be seeing something entirely different depending on your methods—that’s why I suggest looking at the actual output though. Trying to solve this by looking at what the reader prints is tough.

Thanks for the help with figcaption. That did the trick.