When converting a print book to reflowable ePub in InDesign, I always use the Custom CSS option, available in InDesign’s ePub export dialog.

Adding an external, custom CSS file makes it easy (where possible) to tweak the final output to match as closely as possible the print version of the book.

InDesign supports this workflow, by displaying the class name of a paragraph style right inside the paragraph style definition window.

The problem starts when your paragraph style resides in a paragraph style group.

Take a look at this screenshot:

Paragraph Style Tagging

Near (1), InDesign shows you the current class name of your paragraph style. So this means that in your custom CSS file, you should easily be able to refer to your paragraph style as follows:

p.AWChapterNumber{
//Custom CSS goes here
}

The thing to be aware of, though, it that referring in this way to your paragraph style will not work if that paragraph style is in a group.

In my case, here’s a shot of the paragraph style panel:

Paragraph Style Panel

As you can see, the paragraph style AWChapterNumber resides inside the Chapter Openings group.

Attempting to refer to this style with the CSS above fails. Why?

I opened the ePub in SIGIL (which is still the easiest way to examine the inner workings of an ePub on Windows, in my opinion). This is what I saw:

SIGIL screenshot

The conclusion: InDesign prefixes the name of the style group the paragraph style is in to the name of the style itself, and separates the paragraph’s group name and style name with an underscore.

So if you ever want to refer to a paragraph style in a custom CSS file, and that paragraph style sits in a style group, you must remember to first include the group name (by the way, note that spaces in the group name have been converted to hyphens).

I think that this fact should somehow be made visible in the Export Details panel above. The Export Details panel certainly misleads me into thinking that I can refer to the paragraph style as AWChapterNumber alone. There is no mention of the fact that this must be prefixed with Chapter-Openings_ in the custom CSS file.

This have changed for the better?

Now, I’m almost certain that something’s changed. I can’t say for certain when it happened, but in versions of InDesign prior to CC2014 all the above was equally valid even if a custom class name was typed into the field (near red circle 2 in the screenshot above).

However, doing a little testing with CC2014 shows that now, if a custom class name is added to the paragraph stlye definition, it is possible to refer to the paragraph style directly, without needing to including the name of the paragraph style group.

That’s certainly an improvement!