Anatomy of a Valid EPUB 3 package.opf File

Anatomy of a Valid EPUB 3 package.opf File

The Open Packaging Format (package.opf) file serves as the central manifest, metadata store, and reading-order controller for an EPUB 3 publication. In automated publishing pipelines, build scripts generate package.opf from source XML or Markdown repositories prior to archiving the Open Container Format (OCF) .epub bundle. The META-INF/container.xml file points directly to package.opf via its full-path attribute, allowing reading systems to locate all publication assets.

Conformance with the W3C EPUB 3.3 specification is mandatory for ingestion by downstream distribution platforms and reading systems.

Complete Working Example

<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="pub-id" xml:lang="en">
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
    <dc:identifier id="pub-id">urn:uuid:9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d</dc:identifier>
    <dc:title>Automated Prepress Pipelines</dc:title>
    <dc:language>en</dc:language>
    <dc:creator>A. Developer</dc:creator>
    <meta property="dcterms:modified">2026-11-20T12:00:00Z</meta>
  </metadata>
  <manifest>
    <item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
    <item id="cover-img" href="images/cover.jpg" media-type="image/jpeg" properties="cover-image"/>
    <item id="css" href="styles/stylesheet.css" media-type="text/css"/>
    <item id="ch01" href="text/chapter01.xhtml" media-type="application/xhtml+xml"/>
    <item id="ch02" href="text/chapter02.xhtml" media-type="application/xhtml+xml"/>
  </manifest>
  <spine page-progression-direction="ltr">
    <itemref idref="nav" linear="no"/>
    <itemref idref="ch01"/>
    <itemref idref="ch02"/>
  </spine>
</package>

Parameter & Element Breakdown

Flag / ElementRequiredFunction & Technical Behavior
<package>YesRoot container element of the OPF package document, referenced by META-INF/container.xml via full-path.
xmlnsYesDeclares the default OPF XML namespace ([http://www.idpf.org/2007/opf](http://www.idpf.org/2007/opf)).
versionYesSpecifies the package specification version; must be "3.0" for all EPUB 3 releases, including EPUB 3.3.
unique-identifierYesHolds an IDREF matching the id attribute of the primary <dc:identifier> element used to identify the publication.
xml:langNoSets the default BCP 47 language code for human-readable text within package.opf metadata elements.
<metadata>YesEncapsulates Dublin Core bibliographic elements, rendering directives, and revision timestamps.
xmlns:dcYesBinds the dc prefix to the Dublin Core Metadata Element Set namespace ([http://purl.org/dc/elements/1.1/](http://purl.org/dc/elements/1.1/)).
<dc:identifier>YesContains the primary publication identifier (UUID, ISBN, or URI); requires an id attribute matching unique-identifier.
<dc:title>YesDefines the publication title; at least one non-empty instance is mandatory.
<dc:language>YesDeclares the primary language of the publication content using a valid BCP 47 language tag.
<dc:creator>NoIdentifies the primary author, editor, or corporate entity responsible for creating the publication content.
<meta property="dcterms:modified">YesRecords the last modification timestamp in strict UTC ISO 8601 format (CCYY-MM-DDThh:mm:ssZ). Exactly one unrefined instance is required.
<manifest>YesLists every publication resource bundled in the OCF archive except mimetype, META-INF/*, and package.opf itself.
<item>YesRegisters an individual file resource inside the <manifest> block.
id (<item>)YesAssigns a document-unique XML NCName identifier to the resource for <spine> and manifest fallback references.
href (<item>)YesSpecifies the relative IRI path from package.opf to the resource; must omit fragment identifiers.
media-type (<item>)YesDeclares the IANA MIME type of the resource (e.g., application/xhtml+xml, text/css, image/jpeg).
properties (<item>)ConditionalSpace-separated list of manifest properties. Exactly one XHTML item must carry nav; cover-image designates the cover asset.
<spine>YesEstablishes the default linear reading order of the publication’s top-level content documents.
page-progression-directionNoSets global page turn direction across the publication (ltr, rtl, or default).
<itemref>YesAppends a content document to the reading sequence; at least one primary (linear="yes") entry is required.
idref (<itemref>)YesReferences the id attribute of an XHTML or SVG <item> in <manifest>, or a foreign resource <item> with a fallback chain terminating in an XHTML or SVG Content Document.
linear (<itemref>)NoIndicates whether the item belongs to the primary reading flow (yes, default) or auxiliary non-linear content (no).

Validation & Common Pitfalls

  • Verify XML well-formedness and EPUB conformance: Validate syntax first with xmllint --noout package.opf, then execute epubcheck --mode opf package.opf for standalone package checking or epubcheck publication.epub against the packaged container to verify cross-document resource resolution and exit with status 0 on valid builds.
  • Unmanifested assets, missing files, and nav property errors: Every stylesheet, font, image, and XHTML document bundled in the OCF container must appear as a <manifest> <item>, and exactly one XHTML document must declare properties="nav". Omitting a referenced resource from <manifest> triggers RSC-008, leaving unmanifested files inside the archive triggers OPF-003, referencing a file absent from the ZIP container triggers RSC-007, and omitting properties="nav" triggers OPF-015 or RSC-005 (whereas OPF-014 indicates an invalid or mismatched properties value on an <item>).
  • Invalid dcterms:modified timestamp syntax: The <meta property="dcterms:modified"> element must contain a single timestamp formatted strictly as CCYY-MM-DDThh:mm:ssZ in Coordinated Universal Time. Including local timezone offsets (such as +05:30), spaces, or fractional seconds fails EPUB 3.3 schema validation.
  • Un-falled-back foreign resources or empty primary <spine>: Every <itemref> idref attribute must resolve either to an EPUB Content Document (application/xhtml+xml or image/svg+xml) or to a foreign resource <item> whose fallback attribute chain terminates in an EPUB Content Document. Referencing CSS files or raster images directly in <spine> without a valid fallback chain, or marking every <itemref> as linear="no" without at least one primary reading item, breaks reading-system traversal.
  • Case-sensitive href paths, IRIs, and directory separators: Every <item> href attribute is a case-sensitive IRI resolved relative to package.opf and must match the exact file path inside the OCF ZIP archive. Spaces are forbidden and must be percent-encoded (%20), backslashes (\) are invalid path separators, and while raw UTF-8 non-ASCII characters are permitted in IRIs, percent-encoding them prevents PKG-010 and PKG-012 filename portability warnings during epubcheck validation.

You may also like

See All Posts →