LEARNING OBJECTIVES โต
- Synthesize all core EPUB 3 specifications into a publication-ready, commercial-grade digital book.
- Construct the entire container file hierarchy from
mimetypetoMETA-INF/container.xmlandpackage.opf. - Author structured XHTML content documents featuring MathML formulas, pop-up footnotes, sidebars, and DPUB-ARIA landmarks.
- Implement production-grade CSS supporting fluid reflow, dark mode safety, and pagination break controls.
- Build a tri-part Navigation Document (
nav.xhtml) with TOC, Landmarks, and Print Page-Lists. - Execute automated packaging and verify 100% compliance with
epubcheckand Ace by DAISY.
๐ The Mental Model & Story (Intuitive Foundation)
Assembling an EPUB 3 publication is like crafting a mechanical Swiss chronometer. Each individual gearโstrict XML syntax, Dublin Core metadata, semantic DPUB-ARIA landmarks, pagination-safe CSS, uncompressed byte offsets, and navigation treesโmust mesh with microscopic precision.
+-----------------------------------------------------------------------------------+
| END-TO-END PUBLISHING PIPELINE |
+-----------------------------------------------------------------------------------+
[Step 1: Scaffolding] -> mimetype (uncompressed) + META-INF/container.xml
|
[Step 2: Content XHTML] -> Strict XHTML5 + MathML + Pop-up Footnotes + ARIA Roles
|
[Step 3: Styling Engine] -> Fluid CSS3 + Break Controls + Dark Mode Safety
|
[Step 4: Navigation] -> nav.xhtml (TOC + Landmarks + Page-List)
|
[Step 5: Master OPF] -> package.opf (Metadata + Manifest + Spine)
|
[Step 6: Packaging & QA] -> OCF Zip -> EpubCheck Validation -> Ace DAISY Audit
|
v
[DISTRIBUTION: Apple Books, Amazon Kindle KFX, Kobo, Thorium Reader]
When every piece is built according to open W3C standards, your book glides effortlessly across Apple Books on iOS, Kindle Paperwhite on E-Ink, and screen readers on Windows with flawless typographic elegance.
Technical Deep Dive & Specifications
Complete Project File Tree Architecture
Below is the production filesystem layout for our complete technical book, "Architectures of Resilient Systems":
resilient-systems-project/
โโโ mimetype <- Exact 20 bytes: application/epub+zip
โโโ META-INF/
โ โโโ container.xml <- Container bootstrap pointer
โโโ EPUB/
โโโ package.opf <- Master Package Document
โโโ text/
โ โโโ cover.xhtml <- Book Cover Page
โ โโโ nav.xhtml <- Primary Navigation Document
โ โโโ ch01_concurrency.xhtml <- Chapter 1 (Content + MathML + Footnotes)
โ โโโ ch02_consensus.xhtml <- Chapter 2 (Content + Complex Tables)
โ โโโ glossary.xhtml <- Glossary of Terms
โโโ styles/
โ โโโ epub.css <- Production Paged Media Stylesheet
โโโ images/
โโโ cover.svg <- Vector Cover Artwork
โโโ raft_diagram.svg <- Accessible Architectural SVG
๐ป Interactive Code Playground
Let's examine the core files that make up this complete publication.
1. META-INF/container.xml
2. EPUB/package.opf (Master Control Center)
3. EPUB/text/ch01_concurrency.xhtml (Chapter 1)
4. EPUB/text/nav.xhtml (Navigation Document)
5. EPUB/styles/epub.css (Hardened Typography)
<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container><?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf"
unique-identifier="pub-id"
version="3.0"
prefix="rendition: http://www.idpf.org/vocab/rendition/# schema: http://schema.org/">
<!-- 1. METADATA & ACCESSIBILITY -->
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:identifier id="pub-id">urn:uuid:7c8b9d0e-1f2a-3b4c-5d6e-7f8a9b0c1d2e</dc:identifier>
<dc:title>Architectures of Resilient Systems</dc:title>
<dc:creator id="aut">Dr. Marcus Vance</dc:creator>
<meta refines="#aut" property="role" scheme="marc:relators">aut</meta>
<dc:publisher>Distributed Systems Press</dc:publisher>
<dc:language>en-US</dc:language>
<meta property="dcterms:modified">2026-08-20T18:00:00Z</meta>
<!-- Schema.org Accessibility Metadata -->
<meta property="schema:accessMode">textual</meta>
<meta property="schema:accessMode">visual</meta>
<meta property="schema:accessModeSufficient">textual,visual</meta>
<meta property="schema:accessibilityFeature">structuralNavigation</meta>
<meta property="schema:accessibilityFeature">alternativeText</meta>
<meta property="schema:accessibilityFeature">tableOfContents</meta>
<meta property="schema:accessibilityHazard">none</meta>
<meta property="schema:accessibilitySummary">Conforms to WCAG 2.1 AA and EPUB Accessibility 1.1.</meta>
</metadata>
<!-- 2. MANIFEST -->
<manifest>
<item id="nav" href="text/nav.xhtml" media-type="application/xhtml+xml" properties="nav" />
<item id="cover" href="text/cover.xhtml" media-type="application/xhtml+xml" />
<item id="ch01" href="text/ch01_concurrency.xhtml" media-type="application/xhtml+xml" properties="mathml" />
<item id="ch02" href="text/ch02_consensus.xhtml" media-type="application/xhtml+xml" properties="svg" />
<item id="glossary" href="text/glossary.xhtml" media-type="application/xhtml+xml" />
<item id="css" href="styles/epub.css" media-type="text/css" />
<item id="cover-img" href="images/cover.svg" media-type="image/svg+xml" properties="cover-image" />
<item id="diagram-raft" href="images/raft_diagram.svg" media-type="image/svg+xml" />
</manifest>
<!-- 3. SPINE -->
<spine>
<itemref idref="cover" linear="no" />
<itemref idref="nav" />
<itemref idref="ch01" />
<itemref idref="ch02" />
<itemref idref="glossary" />
</spine>
</package>/* Core Layout & Hyphenation */
html, body {
margin: 0;
padding: 0;
font-size: 100%;
line-height: 1.5;
hyphens: auto;
-webkit-hyphens: auto;
}
/* Headings with Orphan Prevention */
h1, h2, h3 {
line-height: 1.2;
break-after: avoid;
page-break-after: avoid;
}
h1 {
font-size: 1.8rem;
margin-top: 1.5em;
margin-bottom: 0.8em;
text-align: center;
break-before: page;
page-break-before: always;
}
p {
margin-top: 0;
margin-bottom: 0;
text-indent: 1.5em;
text-align: justify;
orphans: 2;
widows: 2;
}
h1 + p, h2 + p, p.lead {
text-indent: 0;
}
/* Theme-Safe Callout Box */
aside.callout {
margin: 1.5em 0;
padding: 1em;
border-left: 4px solid #0284c7;
background-color: rgba(2, 132, 199, 0.08);
border-radius: 0 4px 4px 0;
break-inside: avoid;
page-break-inside: avoid;
}
/* MathML formatting */
.math-block {
text-align: center;
margin: 1.5em 0;
break-inside: avoid;
}๐๏ธ Hands-On Exercise
๐ฏ The Challenge: Author and Integrate Chapter 2
Instructions:
- Create
EPUB/text/ch02_consensus.xhtmlcontaining:- Proper XHTML prologue, namespaces (
xmlns,xmlns:epub), andlangtags. - A chapter header for "Chapter 2: Distributed Consensus & Raft".
- A section containing an accessible
<figure>wrapping../images/raft_diagram.svgwith alt text and a<figcaption>.
- Proper XHTML prologue, namespaces (
- Connect
ch02_consensus.xhtmlinto thepackage.opf<manifest>and<spine>. - Update
nav.xhtmlto include Chapter 2 in the Table of Contents.
๐ Starter Code Sandbox
โ ๏ธ Common Pitfalls
- Mismatched Manifest IDs: Declaring
id="chapter-2"in<manifest>but referencingidref="ch02"in<spine>. This triggers an instantOPF-014fatal validation failure. - Forgetting to Update
dcterms:modified: Every time you package a new build of an EPUB, you must update the<meta property="dcterms:modified">timestamp to current UTC time. - Unescaped Special Characters in Titles: Writing
<dc:title>Design & Architecture</dc:title>inpackage.opfwill crash XML parsers. It must be written asDesign & Architecture.
๐ก Pro Tips
- Automate the Build Pipeline: Write an
npm run buildscript that runs XML linting, checks MathML validity, packages the OCF archive, and executesepubcheckandacein a single command. - Multi-Store Testing: Before commercial distribution, test your compiled
.epubin:- Apple Books (macOS / iOS)
- Kindle Previewer 3 (Amazon KF8 / KFX)
- Thorium Reader (W3C Reference Desktop Reader)
๐ Key Takeaways
- EPUB 3 represents a complete, self-contained offline web application packaged inside an OCF-compliant ZIP archive.
- Content documents must adhere to strict XHTML5, lowercase casing, escaped entities, and self-closing tags.
- Semantics should be doubly enriched using
epub:typeand DPUB-ARIArole="doc-*"attributes. - The
package.opffile acts as the master manifest, declaring all assets and defining the spine reading flow. - The
nav.xhtmldocument provides the Table of Contents, reader Landmarks, and physical Print Page Lists. - Build pipelines should enforce automated validation with
epubcheckand Ace by DAISY. - --