The OPF file, traditionally named content.opf, houses the EPUB book's metadata, file manifest, and linear reading order.

This file has a root element package and four child elements:

  1. metadata
  2. manifest
  3. spine
  4. guide

Furthermore, the package node must have the unique-identifier attribute. The .opf file's mimetype is:


The identifier's id attribute should equal the unique-identifier attribute from the package element.

<?xml version="1.0"?> <package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId"> <metadata> </metadata> <manifest> </manifest> <spine toc="ncx"> </spine> <guide> </guide> </package>

Metadata Element

The metadata element contains all the metadata information for a particular EPUB file. Three metadata tags are required (though many more are available):

  • title (title of the book)
  • language (RFC 3066 format or RFC 4646)
  • identifier (unique identifier ie ISBN or a URL)

<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> <dc:title>Pride and Prejudice</dc:title> <dc:language>en</dc:language> <dc:identifier id="BookId" opf:scheme="ISBN">123456789X</dc:identifier> <dc:creator opf:file-as="Austen, Jane" opf:role="aut">Jane Austen</dc:creator> </metadata>

Manifest Element

The manifest element lists all the files contained in the package. Each file is represented by an item element, and has the attributes:

  • id
  • href
  • media-type.

All XHTML (content documents), stylesheets, images or other media, embedded fonts, and the NCX file should be listed here.

Only the .opf file itself, the container.xml, and the mimetype files should not be included.

<manifest> <item id="chapter1" href="chapter1.xhtml" media-type="application/xhtml+xml"/> <item id="stylesheet" href="style.css" media-type="text/css"/> <item id="ch1-pic" href="ch1-pic.png" media-type="image/png"/> <item id="myfont" href="css/myfont.otf" media-type="application/x-font-opentype"/> <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/> </manifest>

Note that in the section above, an arbitrary media-type is given to the included font file, even though no mimetype exists for fonts.

Spine Element

The spine element lists all the XHTML content documents in their linear reading order. Also, any content document that can be reached through linking or the table of contents must be listed as well. The toc attribute of spine must contain the id of the NCX file listed in the manifest. Each itemref element's idref is set to the id of its respective content document.

<spine toc="ncx"> <itemref idref="chapter1" /> </spine>

Guide Element

The guide element is an optional element for the purpose of identifying fundamental structural components of the book. Each reference element has the attributes type, title, href. Files referenced in href must be listed in the manifest, and are allowed to have an element identifier (e.g. #figures in the example).

<guide> <reference type="loi" title="List Of Illustrations" href="appendix.html#figures" /> </guide>

EPUB (short for electronic publication; sometimes styled ePub) is a free and open e-book standard by the International Digital Publishing Forum (IDPF). Files have the extension .epub - wikipedia