Best practices in ePub cover images

by Keith Fahlgren

[Today's guest post is by Keith Fahlgren. - Liza]

The three ePub specifications (OPF, OPS, and OCF) include a lot of detail on ebook metadata and markup, but do not include a technique for describing covers. Despite this omission (a fix is being discussed), there are some widely adopted approaches for marking up covers that will make the cover display correctly in most (but not all) ePub reading systems.

Ensuring the widest interoperability for your cover means including an XHTML cover page (as the first “flow”), a cover image, and bits of OPF metadata to refer to these items using consistent names.

Cover as XHTML

To get started, here’s an extremely minimal XHTML cover page that serves only to reference the cover image. This file should be named cover.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="">
    <style type="text/css"> img { max-width: 100%; } </style>
    <div id="cover-image">
      <img src="the_cover.jpg" alt="Title of this Thing, Second Edition"/>

Cover as image

Next, make sure the cover image itself, probably in JPEG (it’s a photo) or PNG (it isn’t) format, is scaled to less than 1000px in width and height. Choosing the perfect size for ebook images is still an open question given the growing range of screen sizes, but shrinking to 1000px should ensure that you don’t trigger a (historical) bug that crashed a popular mobile reading system by giving it a cover too large in size.

Covered in metadata

The real fun¡ is in the OPF file. First, make sure you have references to both the image and XHTML covers in your OPF manifest. The id attributes below are important to note:

<item id="cover"       href="cover.html"    media-type="application/xhtml+xml"/>
<item id="cover-image" href="the_cover.jpg" media-type="image/jpeg"/>

Using the same value as the id attribute for the XHTML cover, add an initial itemref to the spine element that refers to the cover page but is not linear. This tells reading systems (like ADE) what position the XHTML cover should have in the document (must be first to trigger cover behavior), but asks that it not be displayed to the reader as part of the “linear reading order of the publication.”

<spine toc="ncxtoc">
  <itemref idref="cover" linear="no"/>
  <itemref idref="normal-first-content"/>

The cover image also gets a special bit of metadata: a reference as a meta element inside the OPF metadata block. It’s critical that this use name="cover" as a signal to reading systems that would prefer to show covers as images rather than covers as XHTML:

<meta name="cover" content="cover-image"/>

Finally, it’s a good choice to include an OPF guide reference to your XHTML cover as a final hint to reading systems of what’s going on:

  <reference href="cover.html" type="cover" title="Cover"/>

If you’ve gone to all this trouble to include a cover in your ebook, please don’t forget that readers expect it to be nice & in color.

Other approaches

Adobe’s EPUB Best Practices recommends a SVG-based approach to cover images. While it’s an interesting technique that can integrate well with Adobe Digital Editions, I haven’t found it to be widely supported.