EPUB 3: The Open Standard for Ebooks and Digital Publications
What Is EPUB 3?
EPUB 3 is the current version of the open ebook standard maintained by the W3C (World Wide Web Consortium) — having migrated from the IDPF (International Digital Publishing Forum) in 2017. EPUB stands for Electronic Publication. Version 3 (EPUB 3.3 is the current specification as of 2023) is built on open web standards: HTML5, CSS3, SVG, and JavaScript form the content layer, while a ZIP-based container with XML metadata provides the packaging.
EPUB 3 files use the .epub extension. They are the native format of:
- Apple Books (iOS, macOS)
- Kobo e-readers and apps
- Google Play Books
- Overdrive/Libby (public library lending)
- Adobe Digital Editions
- Most open-source readers (Calibre, Foliate, ReadEra)
Amazon Kindle uses its own .mobi/.azw3/.kfx formats, but Amazon's KindleGen and Kindle Previewer both convert EPUB as input.
EPUB File Structure
An EPUB 3 file is a ZIP archive with a specific internal structure:
ebook.epub (ZIP archive)
├── mimetype ← must be first; uncompressed; "application/epub+zip"
├── META-INF/
│ ├── container.xml ← points to the OPF package document
│ └── encryption.xml ← (optional) DRM/font obfuscation info
└── EPUB/ (or OEBPS/ — any name)
├── content.opf ← OPF: Package Document (metadata + manifest + spine)
├── nav.xhtml ← EPUB Navigation Document (Table of Contents)
├── toc.ncx ← (optional) NCX for EPUB 2 backward compatibility
├── css/
│ └── styles.css ← stylesheet
├── images/
│ ├── cover.jpg ← cover image
│ └── figure1.png
└── xhtml/
├── chapter01.xhtml ← content documents (valid XHTML5)
├── chapter02.xhtml
└── chapter03.xhtml
The mimetype File
The mimetype file must contain exactly application/epub+zip with no newline, and must be the first file in the ZIP archive, stored uncompressed. This enables EPUB detection by magic bytes without full ZIP inspection.
The OPF Package Document (content.opf)
The Package Document is the spine of the EPUB — it lists all resources, defines reading order, and contains metadata:
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf"
version="3.0"
unique-identifier="uid">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:identifier id="uid">urn:isbn:978-3-16-148410-0</dc:identifier>
<dc:title>The Art of Code</dc:title>
<dc:creator id="author">Jane Smith</dc:creator>
<meta refines="#author" property="role" scheme="marc:relators">aut</meta>
<dc:language>en</dc:language>
<dc:publisher>Open Books Ltd</dc:publisher>
<dc:date>2024-01-15</dc:date>
<dc:description>A technical book about programming as art.</dc:description>
<meta property="dcterms:modified">2024-01-15T10:00:00Z</meta>
<meta name="cover" content="cover-image"/>
</metadata>
<manifest>
<!-- Every file in the EPUB must be listed here -->
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml"
properties="nav"/>
<item id="cover-image" href="images/cover.jpg" media-type="image/jpeg"
properties="cover-image"/>
<item id="css" href="css/styles.css" media-type="text/css"/>
<item id="ch01" href="xhtml/chapter01.xhtml" media-type="application/xhtml+xml"/>
<item id="ch02" href="xhtml/chapter02.xhtml" media-type="application/xhtml+xml"/>
<item id="ch03" href="xhtml/chapter03.xhtml" media-type="application/xhtml+xml"/>
</manifest>
<spine>
<!-- Reading order: itemref elements point to manifest items -->
<itemref idref="ch01"/>
<itemref idref="ch02"/>
<itemref idref="ch03"/>
</spine>
</package>
The Navigation Document (nav.xhtml)
Replaces the NCX TOC from EPUB 2:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops">
<head><title>Table of Contents</title></head>
<body>
<nav epub:type="toc" id="toc">
<h1>Table of Contents</h1>
<ol>
<li><a href="xhtml/chapter01.xhtml">Chapter 1: Introduction</a></li>
<li><a href="xhtml/chapter02.xhtml#sec2">Chapter 2: Core Concepts</a>
<ol>
<li><a href="xhtml/chapter02.xhtml#sec2-1">2.1 Variables</a></li>
<li><a href="xhtml/chapter02.xhtml#sec2-2">2.2 Functions</a></li>
</ol>
</li>
<li><a href="xhtml/chapter03.xhtml">Chapter 3: Advanced Topics</a></li>
</ol>
</nav>
<nav epub:type="landmarks">
<ol>
<li><a epub:type="cover" href="xhtml/cover.xhtml">Cover</a></li>
<li><a epub:type="toc" href="nav.xhtml#toc">Table of Contents</a></li>
<li><a epub:type="bodymatter" href="xhtml/chapter01.xhtml">Start of Content</a></li>
</ol>
</nav>
</body>
</html>
Content Documents: XHTML5
Each chapter is a valid XHTML5 document:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops"
xml:lang="en" lang="en">
<head>
<title>Chapter 1</title>
<link rel="stylesheet" href="../css/styles.css" type="text/css"/>
</head>
<body>
<section epub:type="chapter" aria-labelledby="ch1-title">
<h1 id="ch1-title">Chapter 1: Introduction</h1>
<p>Opening paragraph of the chapter...</p>
<!-- Ruby text (CJK annotations) -->
<ruby>漢<rt>かん</rt>字<rt>じ</rt></ruby>
<!-- Figure with caption -->
<figure>
<img src="../images/figure1.png" alt="Architecture diagram showing three layers"/>
<figcaption>Figure 1.1: System architecture</figcaption>
</figure>
<!-- Code listing -->
<pre><code class="language-python">def greet(name: str) -> str:
return f"Hello, {name}!"</code></pre>
<!-- Aside / sidebar -->
<aside epub:type="sidebar">
<h2>Key Concept</h2>
<p>Variables store data temporarily...</p>
</aside>
</section>
</body>
</html>
EPUB 3 Features Over EPUB 2
| Feature | EPUB 2 | EPUB 3 |
|---|---|---|
| Content standard | XHTML 1.1 | XHTML5 / HTML5 |
| CSS | CSS 2.1 | CSS 3 (full) |
| Audio/Video | No | Yes (<audio>, <video>) |
| JavaScript | No | Yes (Scripted Publications) |
| SVG inline | No | Yes |
| MathML | No | Yes |
| Ruby text | No | Yes |
| Fixed layout | No | Yes |
| Accessibility (ARIA) | Limited | Full ARIA + WCAG 2 |
| Media overlays (narration sync) | No | Yes (SMIL sync audio+text) |
| Rightward/vertical text | Limited | Yes (CJK vertical) |
| Fonts | Limited | WOFF/WOFF2 embedded |
Creating EPUB 3 with Python: ebooklib
from ebooklib import epub
# Create book
book = epub.EpubBook()
book.set_identifier('art-of-code-001')
book.set_title('The Art of Code')
book.set_language('en')
book.add_author('Jane Smith')
book.add_metadata('DC', 'publisher', 'Open Books Ltd')
# Add cover image
with open('cover.jpg', 'rb') as f:
book.set_cover('images/cover.jpg', f.read())
# Create chapters
ch1 = epub.EpubHtml(
title='Chapter 1: Introduction',
file_name='xhtml/chapter01.xhtml',
lang='en'
)
ch1.content = '''<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Chapter 1</title></head>
<body>
<h1>Chapter 1: Introduction</h1>
<p>Welcome to the art of code...</p>
</body>
</html>'''
ch2 = epub.EpubHtml(title='Chapter 2', file_name='xhtml/chapter02.xhtml', lang='en')
ch2.content = '<html><body><h1>Chapter 2</h1><p>Content...</p></body></html>'
book.add_item(ch1)
book.add_item(ch2)
# Add CSS
css = epub.EpubItem(
uid='style',
file_name='css/styles.css',
media_type='text/css',
content='body { font-family: Georgia, serif; line-height: 1.6; }'
)
book.add_item(css)
# Define table of contents
book.toc = (epub.Link('xhtml/chapter01.xhtml', 'Introduction', 'ch1'),
epub.Link('xhtml/chapter02.xhtml', 'Chapter 2', 'ch2'))
# Add navigation files
book.add_item(epub.EpubNcx())
book.add_item(epub.EpubNav())
# Define reading order (spine)
book.spine = ['nav', ch1, ch2]
# Write EPUB file
epub.write_epub('art_of_code.epub', book)
Converting to/from EPUB
# DOCX → EPUB (via Pandoc)
pandoc input.docx -o output.epub \
--epub-cover-image=cover.jpg \
--epub-metadata=metadata.xml \
--toc
# EPUB → MOBI/AZW3 (for Kindle)
ebook-convert input.epub output.mobi # via Calibre CLI
# EPUB → PDF
ebook-convert input.epub output.pdf # via Calibre CLI
# Validate EPUB 3
epubcheck input.epub
EPUBCheck (free Java tool from W3C) is the authoritative EPUB validator. Always run it before publishing.
EPUB 3 Accessibility
EPUB 3 supports full ARIA + WCAG 2 accessibility:
<!-- Required accessibility metadata in OPF -->
<meta property="schema:accessMode">textual</meta>
<meta property="schema:accessMode">visual</meta>
<meta property="schema:accessibilityFeature">structuralNavigation</meta>
<meta property="schema:accessibilityFeature">alternativeText</meta>
<meta property="schema:accessibilityHazard">none</meta>
<meta property="schema:accessibilitySummary">
This publication conforms to WCAG 2.1 Level AA.
</meta>
Content requirements for EPUB Accessibility 1.1 (ISO/IEC TS 23761):
- All images have
alttext - Logical reading order via spine and HTML heading hierarchy
epub:typesemantic inflection on structural elements- Language declared in
<html lang="en"> - Color not the sole means of conveying information
- Keyboard-navigable reading experience
Practical Tips
- Always run EPUBCheck — most publishing platforms (Kobo, Apple Books) reject EPUBs that fail validation
- Test on real devices — rendering varies significantly between Kindle, Kobo, Apple Books, and desktop readers
- Fixed layout vs. reflowable: use fixed layout (
<meta name="fixed-layout" content="true"/>) only for children's books or highly visual content — it breaks font scaling and accessibility - Font embedding: always embed fonts (WOFF2); don't rely on system fonts, which vary by device
- Image dimensions: keep cover images 1600×2400 px (2:3 ratio) for best display across devices
- No
<script>if targeting Kindle — Kindle doesn't execute JavaScript in EPUB content - Calibre (free, open-source) is the best tool for desktop EPUB editing, conversion, and library management
EPUB 3's open web standards foundation, rich multimedia support, strong accessibility framework, and universal support across non-Kindle reading platforms make it the standard format for modern digital publishing.
Related conversions
Document conversions that follow this topic naturally: