pen and book
BACK TO TOP ▲

digital publishing reference

 

Lists in EPUB & Kindle Export

Lists (bulleted and numbered) are used in almost every book, somewhere, meaning they will likely be an element you have to export to EPUB, and on through to Kindle. While you can just export with default settings and often get an acceptable result, getting a "better" or "professional" result takes more work, especially if the lists have multiple levels. This essay summarizes the steps and elements for getting that "better" result for both unordered lists (bullets) and ordered lists (numbered) in e-book export.

There are multiple layers to successful and increasingly "optimized" list export, and they interact in some confusing and nonlinear ways. This essay is a concise version of the successive approaches and steps, intended for somewhat advanced users who understand both InDesign formatting and CSS well.

This is a highly "circular" topic as well. Despite considerable editing, there is more repetition and overlap between the sections than I'd like—which is reflective of how it's all one big tangle, in there. Sorry.

v1.00 – Published Online May 2024

Lists in EPUB & Kindle Export
James Gifford


Lists in and from InDesign

Lists in InDesign are composed of paragraphs for each list item, bound together and organized by the options in the Paragraph Style submenu Bullets and Numbering.

For the most part, all general paragraph style and formatting (including borders and shading) is preserved on export to EPUB/Kindle. That makes it simple to both control, or at least pre-shape the export result, and to have a CSS style on which to hang modifications.

The list-related elements and settings, though, are filtered and recast into a different structure. Of those settings, these key options control the export of the list and list elements:

  • The List Type sets the list to either Bullets or Numbers, which determines whether the list items will be exported as part of an unordered or ordered HTML list.
  • The settings under Bullet Character or Numbering Style are largely irrelevant and will be discarded in the export for detault HTML list features.
  • Of the settings under Bullet or Number Position, only the Left Indent and First Line Indent matter.
    • Unless you are designing a very odd print layout for your list, it is recommended that you use standard InDesign practice here, with a positive text indent and a negative first line 'outdent.' This is a 'switch' with a significant effect on the exported style.

Lists into EPUB Export

There are two options for exporting lists into EPUB from InDesign, but we will focus on the more common and useful one (ordered/unordered HTML lists), and leave the "text export" method for more in-depth resources. (This selection is made in the EPUB export menu, under Text. Note that the export options for bulleted and numbered lists can be set independently.)

The assumption, then, is that you are exporting lists to their HTML equivalents. The difference between the two is the type of 'list bracket' applied to each—

<ul>

<li>List item one</li>

<li>List item two</li>

</ul>

—will produce a bulleted—ul—unordered list, while—

<ol>

<li>List item one</li>

<li>List item two</li>

</ol>

—will produce a numbered—ol—ordered list.

All details of the bullet, number, number value and format, positioning, etc. will be controlled by the inherent rules of the HTML browser, or in our case, the EPUB reader. A slight amount of CSS override can be applied—for example, specifying the bullet glyph (disc, circle, square, etc.) Otherwise, only a small amount of spacing and positioning format is possible for the marker. The extensive control InDesign allows, including assigning a character style, is lost.

InDesign styles exported to base CSS, and CSS adjustments, are applied to the list elements, and the export includes the style name—

<ul>

<li class="BULLET">List item one</li>

<li class="BULLET">List item two</li>

</ul>

Also note that, going forward—

  • For the most part, we will focus on bulleted/unordered/<ul> lists, but nearly everything is applicable to numbered lists as well. (The major difference is that numbered lists sometimes require different marker/text spacing.)
  • The term "marker" is meant to refer to both bullets of all styles and item numbers of all formats.

List Formatting within InDesign

So let's back up. A considerable amount of list formatting can be done within InDesign, using the relevant panes of the Paragraph Style menu. The following paragraph style elements will be passed through to the list through the style appled to each list element:

  • Font
  • Size
  • Weight
  • Spacing (Top, Bottom, Left, Right)
  • First line indent (should be outdented)
  • Color
  • Paragraph border
  • Paragraph shading

Most of these style elements apply to export much as they might be expected to, just as they would to non-list paragraphs. The one that doesn't is spacing, mostly top, bottom and left-side. As many newcomers to EPUB export discover, getting the left-side text indent and bullet spacing adjusted is the biggest hurdle in e-book lists, and getting list levels to stack neatly and without excessive spacing is another. Both can be bafflingly resistant to adjustments at both the InDesign and CSS levels.

Setting the Correct List Mode

At the HTML/CSS level, there is a slightly obscure but very important setting: list-style-position. This CSS statement determines whether the marker is outset to the left, away from the list item margin, or inset with the text, with the marker more or less in the first character position of the text. It is quite rare to use the latter and it complicates other formatting, so we assume here you want the list position set to outside. (You are free to set this to inside and experiment on your own with its effect in EPUB, and the format variations that can be achieved.)

To force this setting to outside in the default export, the InDesign list paragraph style should be defined with an outdent (an overall text indent with a first line negative indent). If the indents are left at zero or the first line is positively indented, the export will be tagged inside instead. (This may be a source of confusion for some designers, who have battled other spacing settings without realizing this 'switch' was flipped.)

If for any reason you do not use a first-line outdent in your ID layout — and barring experimentation or a deliberate choice — you will need to add the following statement to the list item style in CSS:

li.BULLET {
list-style-position: outside;
}

The Three-Style Stack

For the most part, we will assume that you have your lists cleanly defined in InDesign and optimized for screen and print layout. This is not the place for a critique or a tutorial on that step. But unless your list needs are very simple, I strongly recommend you use the 'three-style stack' method. It may be overkill for many documents, but especially if you want to carefully optimize both ID/print layout and e-book export of lists, it brings a fine degree of control to the latter.

A three-style stack uses one style for all list items in the middle (call it BULLET), then two child styles for the first item (BULLET-first) and last item (BULLET-last). By allowing you to adjust the top spacing on 'first' and the bottom spacing on 'last,' this (usually otherwise identical) triad allows very fine adjustment of the list within other text. (You can also add other elements, such as bolding the first item, or putting rules above and below the list. But this subtle spacing shift is the first and most useful reason for the method.)

This method is not often needed for print layout (any more), since InDesign now allows the collapse of space between identical paragraphs. Therefore, one list item style with space above and below will 'collapse' to a list with the set top spacing above, the set bottom spacing below, and either no spacing or a redefined (smaller) spacing in between items, for a very balanced, pleasing look. But even in ID, even for print it allows a bit of extra fine-tuning, and in export to EPUB, where none of the automatic spacing adjustment is supported, it is the best method for achieving that same balanced result.

To make it clear, the three styles may be identical within InDesign, achieving the effect there of a single style. But allowing CSS control of the stack components makes fine-tuning of exported lists simple.

List Formatting with Export CSS

List items export from InDesign with the li prefix: li.BULLET, li.BULLET-first, etc. These styles will be included in the export CSS list and can be modified almost without limit by a project CSS file. We'll come back to that.

Oh-Ell, You-Ell, Where Are You?

The savvy HTML/CSS user's next question will be, "What about <ol> and <ul>?" To which the answer is: InDesign doesn't know they exist. Meaning: InDesign does not export a CSS statement for either 'list bracket' and thus leaves their style parameters to reader defaults for both EPUB and Kindle. It is that unadjusted default that causes most of the awkward or downright ugly positioning and spacing of lists in EPUB export.

Since at least some control of this wrapper is useful, the first step, once you have your stripped and ready project CSS file, is to add a definition for these crucial elements:

ul, ol {

}

You can leave it empty for now. (And yes, of course, you can define them separately as well, with or without a shared first definition.) And now we'll come back to that.

Basic List Item CSS

Let's look at the InDesign export style for a simple list item. Assume that the paragraph style BULLET is assigned to each list item (we'll bypass the three-style method here, for simplicity)—

  • This is item one of a test list.
  • This is item two of a test list.
  • This is item three of a test list.

When exported, this is converted to the very basic HTML/CSS structure—

<ul>

<li class="BULLET">This is item one of a test list.</li>

<li class="BULLET">This is item two of a test list.</li>

<li class="BULLET">This is item three of a test list.</li>

</ul>

With basically no fancy formatting in ID, the CSS export for BULLET would look like this—

li.BULLET {
line-height:1.167;
list-style-position:outside;
list-style-type:disc;
margin-bottom:0;
margin-left:12px;
margin-right:0;
margin-top:0;
text-align:left;
text-indent:0;
}

(A number of irrelevant, almost boilerplate statements have been removed. If you're curious, go look at your own export file.)

Most of that should be self-explanatory, but there are some interesting quirks. The line spacing and all four margin values can be set from within ID, or changed in CSS. Other than (default) line spacing, only two spacing values were set in ID for this export: the left margin, at 1 pica or 12 points, which becomes 12 pixels of overall shift leftward from the 'frame' left margin, and a first-line 'outdent' of a matching -12 points.

It doesn't take any sharp eye to see that the outdent value is not exported, as text-indent or any other setting. This is because the export process depends on the EPUB reader to apply its rules to format the list, including bullet type and positioning. The outdent, having done the job of telling the export to use the outside setting, is discarded in favor of this hard-coded rule.

The other setting, list-style-type, seems to always export by default as disc (solid circle); no setting of the list item style in ID changes it, as far as I have been able to determine. You can easily change it in CSS and most readers honor the basic options of circle, square and most numbering schemes. (It can also be set to none, for no marker, but that will likely need experimentation to get all the other spacing and layout to a desired state.)

InDesign Export Faults

With all the basics out of the way, and hopefully comprehensible to anyone with some ID/CSS experience, let's get down to the tough nut at the center of list export: InDesign's faults in managing such exports.

InDesign does four somewhat ugly things when exporting lists:

  • It strips most of the list-specific styling aspects, leaving them to the reader HTML/CSS defaults. Not all of these aspects can be adjusted or reformatted at the CSS level.
  • It leaves the <ol>/<ul> element undefined and thus at the mercy of the reader's defaults.
  • It does not export padding values that can usefully adjust the bullet-to-text distance.
  • It does not apply any formatting or control to the bullet or number markers.

For the most part, styling lists in EPUB is a matter of reasonable mastery of how ID styles export, and their adjustment using CSS. Compensating for these four faults, though, is trickier to deal with and thus requires an extra level of attention and configuration to adjust.

Defining and Adjusting the List Frame

Perhaps the most severe fault in list export is that InDesign leaves the 'list frame' to the default definition of the reader, which often means:

  • Excessive spacing above and below the list, on the order of 36px;
  • Excessive left indent of the list, on the order of 36px or more.

These problems are stacked/magnified if multiple list levels are used, as each level of indent is given this extra/excess/uncontrolled space. It only takes an indent or two for things to get pretty ugly.

The solution is to add that element to your CSS file, as above, and set smaller margins for the 'frame,' down to zero—

ul, ol {

margin: 0;

padding: 0;

}

Or, with slightly more graceful adjustments—

ul, ol {

margin-top: 10px;

margin-bottom: 15px;

margin-left: 0;

padding: 0;

}

When you have levels within your lists, you can use this single definition, or add a definition for each level. (You will probably, for example, want closer top and bottom spacing for each intended level, as well as control of the indent.) Since InDesign puts each successive level ('frame') within a list item, the definition gets a little tricky. For a second indent level, you would use

ul li ul {

...

}

—and for a third—

ul li ul li ul {

...

}

At this level, you will mostly want to adjust margin values; padding, for the most part, should be zeroed out and not otherwise defined unless a border or background shading is to be applied to the overall list frame.

Using Padding to Adjust the Marker Spacing

Where the missing padding value is useful is in spacing the list item text from the bullet or number marker. It should be clear by now that left spacing in InDesign or as set by margin-left is the distance between the left margin of the 'frame' and the position of the marker. Without any further input, the relationship of the marker to the list item text left margin is up to the reader. In most EPUB readers, it's a comfortable if not always optimal spacing. In Kindle, though, it's often too tight, with the bullet or number occupying one character width of space in from of the left margin.

The tool to adjust this spacing is CSS padding, an element which is globally not exported by InDesign. A padding value will work on all sides of a list element, through its applied CSS style, and will interact with margin values in the standard way: margin defines space outside the "box" around the element, while padding defines space around the inside of that box — and they add up, invisibly if there is no border or background color to show the dividing point..

So with all else being the same, adding a statement such as this—

li.BULLET {
padding-left: 10px;
}

—should give a starting point to pleasing bullet-to-text spacing.

It might occur to you that text-indent also plays some role here, but what that CSS statement does is move the entire first line, marker and all, in or out by any relative amount specified. It does not mesh with the left margin or left padding settings, and is not generally useful for list formatting.

Adjusting the Marker Formatting

There is no simple way to adjust the formatting of the marker (bullet or number) in a list export. All of the InDesign styling is stripped, leaving it entirely to the rules and defaults of the reader's methods for formatting ordered/unordered lists.

The one CSS statement that can be used is list-style-type, which can be used with most of the standard list marker definitions to change the bullet to a disc, circle or square, or to override it to several kinds of numbering. It can also be useful to preserve all list item formatting but without any marker, by using none as the argument.

If you want an extraordinary degree of control over list items, including the marker, you will want to look into the "Text" export option for lists. This breaks the list components out into individual elements, freed from the constraints of a list structure, including a marker glyph with its own character style, but requires advanced skills with editing both CSS and XHTML files to fully exploit.

Summing Up: a 'TL;DR' List

In short form for the real pros (and those who are now pros), here are the useful things you can do by combining InDesign formatting, export to un/ordered lists and CSS overrides of the list-frame and list-item elements:

  • Control the list frame or bounding box by adding margin, padding, border or background color to a <ul> and/or <ol> definition added to your CSS file. You will normally want to remove or minimize the default left margin readers apply, and adjust if not remove the excess top and bottom spacing.
  • Control all basic font and paragraph issues, including line and margin spacing, with InDesign settings or CSS statements applied to the list item style. Moving list items left past the defined margin can be done with a negative value for margin-left in the item's CSS style.
    • The 'three element' style method can allow very fine control over list positioning in EPUB export, similar to what InDesign's many spacing controls allow.
  • Control border or background color around list items using either InDesign settings or CSS, but CSS will be required to set padding values on all sides to align these elements with the text.
    • Note that a very effective formatting technique can be contrasting or complementary colors in the overall list frame and the list items.
  • Set the marker type using list-style-type in the list item CSS style.
  • Set the distance between the marker and the list item left text margin using padding-left in the style definition.


Site & contents ©1999-2024 Nitrosyncretic Press LLC  —  CONTACT  —  sitemap