Electric Book Works Web, mobile and print publications

Thinking ahead: styles and tag names

When exporting to epub, InDesign uses your style names as part of the tags in the ebook’s XHTML code.

CS3 gives every paragraph a <p> tag, and then includes with that tag a description of what kind of paragraph it is, based on your style name. If your style name for first-level headings is “head_a”, InDesign CS3 will tag those headings like this:

<p class=”head_a”>
 Your heading

If you’ve correctly used a Table of Contents in InDesign, CS4 will give every heading (if included in your TOC style) an <h*> tag, with a class named for your style name. For instance:

<h1 class=”head_a”>
 Your heading

Tech note: We are assuming here that you’re not using any of InDesign’s XML-tagging features. For advanced users, these are worth exploring. In InDesign, tags are separate from style names, and require that you follow a set DTD/Schema for your XML tags.

Local formatting

In InDesign CS3, only defined styles (paragraph styles, character styles and object styles) are exported to epub; all local formatting is discarded when you export to epub.

This means that if you want a single word or phrase in bold type, you need to create a character style (e.g. bold_text), and apply this character style to all of the text that you need to be bold. If you then decided that you want some of those words bold and italic, then you must create a second style to apply to those words to be turned bold and italic.

In InDesign CS4, you get to choose when exporting to epub whether to keep your local formatting or use defined styles instead. We recommend not using local formatting for your styles, because exporting local formatting to epub makes a mess of your XHTML and CSS code, which then makes it far harder to change and manage text and formatting in the epub. So, it’s still always strongly recommended to avoid any local formatting, and to only use styles for the appearance of text.

Empty lines

Never use empty lines or paragraphs to create space in your books (line spaces created by typing paragraph marks). They will just get ignored in the XHTML of your ebook, so they are effectively lost in the epub. Instead, use styles to add spacing before and after paragraph styles, especially headings and blockquotes.

Search for empty paragraph marks by searching for two ‘End of paragraph’ marks, and solve each instance using the paragraph style’s before-and-after spacing. You may need to create a few new paragraph styles for this to work (e.g. a block quote of three paragraphs would need three separate paragraph styles: a ‘blockquote_first’ with space above, ‘blockquote_next’ with an indented first line, and a ‘blockquote_last’ style with space after.)

Arthur Attwell 17 February 2010
This information is more than two years old, and may no longer be accurate. Contact us to check, or log an issue on GitHub.