Summary

Providing a table of contents allows readers to more easily understand and navigate the content of a publication.

Techniques

Examples

Example 1 — Basic links

A table of contents is an ordered list of links into the content.

<nav role="doc-toc" epub:type="toc" id="toc">
<ol>
  <li>
	<a href="s01.xhtml">A simple link</a>
  </li>
  …
</ol>
</nav>
Example 2 — Nested entries

Ordered lists are nested to reproduce the hierarchy of the publication. A span is used to represent an unlinked heading.

<nav role="doc-toc" epub:type="toc" id="toc">
<ol>
  …
  <li>
	<a href="s03.xhtml">A linked heading</a>
	<ol>
	  <li><a href="s03-01.xhtml">Subsection</a>
	  …
	</ol>
  </li>
  <li>
	<span class="navhd">An unlinked heading</span>
	<ol>
	  <li>
		<a href="s04-01.xhtml">Subsection</a>
	  </li>
	  …
	</ol>
  </li>
  …
</nav>
Example 3 — TOC with hidden branches (EPUB-only)

The following example hides branches of the table of contents from visual rendering. These branches are normally not accessible to anyone, but in EPUB 3 the hidden attribute has special handling that is supposed to allow the branches to be viewable when the reading system renders the table of contents.

<nav role="doc-toc" epub:type="toc" id="toc">
<ol>
  …
  <li>
	<a href="s05.xhtml">A linked heading</a>
	<ol hidden="hidden">
	  <li>
		<a href="s05-01.xhtml">Hidden subsection</a>
	  </li>
	  …
	</ol>
  </li>
  …
</ol>
</nav>

Explanation

The table of contents is one of the key methods users use to move around the content of a publication, as it provides users easy access to the major sections of the publication. This, in turn, simplifies quick traversal and random inspection of the content.

A table of contents is typically constructed using an ordered list (ol) inside of a nav element, but the requirements for specific technologies are listed below.

EPUB 3

In EPUB 3, publications must provide a table of contents in the EPUB navigation document (the toc nav).

Each list item must either contain a single link (a) to a section of the document, or a link or heading (span) followed by a list of subsections.

If the pronunciation of a link will be ambiguous or incomplete due to embedded images, math content, or other content without intrinsic text, a title attribute must be attached containing an alternate pronunciation.

If an author intends to include the table of contents in the spine of the publication, the hidden attribute can be used to hide branches from the visual rendering. EPUB user agents are required to ignore this attribute when they present the table of contents to users outside of the spine (i.e., the hidden links will be available in the user agent-generated table of contents).

EPUB 2

EPUB 2 makes use of the DAISY NCX file for provision of a table of contents. The entries of the table of contents are constructed using navPoint elements. These elements can be nested to create a hierarchical list of navigation points.

References

Frequently Asked Questions

Why does EPUB 3 allow NCX files, and do I need to include one?

The NCX file is allowed for forwards compatibility purposes only. An EPUB 2 user agents may open an EPUB 3 publication, but it will not be able to use the new navigation document format.

You can ignore the NCX file if your book won't render properly as EPUB 2 content, or if you aren't targeting cross-compatibility.

Your publication may still open on EPUB 2 user agents even without an NCX. Some user agents, like Adobe Digital Editions, will not provide navigation by table of contents but will open the publication.