InDesign Object Styles Convert to DIV classes in EPUB Export
If you've been exporting EPUB files, then you're likely already aware that EPUB is basically HTML with a little CSS, and that InDesign converts all its paragraph and character styles to CSS classes. For example, if you have a paragraph style called "para intro" then the exported xhtml file is written as <p class="para-intro">. ?Similarly, character styles (even if they're used inside nested or grep styles) are converted into span classes:
So if paragraph and character styles should be converted, then why not object styles, too? Indeed, they are: object styles applied to a frame get converted into DIV classes in the xhtml, and are added to the CSS file, too.
This turns out to be very helpful when formatting images and captions, for example. You can group an image and a caption together and give the group an object style. The object style doesn't have to look like anything in InDesign (it could be "empty" in its definition), but when you export the EPUB file and crack it open, you'll see the div class. Here's the xhtml file from an InDesign document in which I had applied the "imagewrap" object style to a group, and made that group inline where I wanted it in the story:
Note that each object inside the group is given its own div tag, and you end up with two different divs (one for the generic group, and one for the object style). Why? Because InDesign is trying to make sure you have to work hard. I don't know; seems like a bug to me. So when you're cleaning up the xhtml files (you almost always have to), you can remove the extra div and tags, to ensure that this is a single div:
Here is what the EPUB looks like with the figure and the caption appearing between the paragraphs:
Now you can style your group in the .css file. For example, in this case, I'll change the "image-wrap" class to force a wrap (float) with a background color:
The result is dramatically different:
Object styles can be used in all kinds of ways to help speed up the process of formatting your EPUB documents.