Blog

EPUB3 Navigation document

Written by: Ori Idan, Helicon Books CEO


EPUB version 3.0 included a new type of file: the Navigation document.

This file supersedes the old NCX file used in EPUB version 2. The NCX may still be included for compatability with older readers, however it is not necessary any more.

This file is very unique since it is meant to be both machine and human readable. It is actually a standard XHTML with few limitaions, in this article I will explore the structure of this file and how to use it.

This file can be used for two main purposes:

  1. Supply the reading system with table of contents to display when the user asks for table of contents.

  2. Display table of contents or any other contents to user as standard HTML document.

 

One common use of such a file is as a table of contents at the beginning of a document where the reading system can display the same list (or another list) when the user asks for table of contents.

In order to use a file as a navigation document, it should be declared in the manifest with properties="nav" in the item tag of referencing the navigation document. If you want this file contents to be seen when reading the book, you can add it as any other content file to the spine element of the package file.

The machine readable part of this file is inside a nav element. There can be more then one such element. The nav element is one of the new semantic tags in HTML5, see my article: "EPUB3 semantic tags"

Since this part is machine readable there are few limitations on what tags can be included inside this nav tag. It can however use CSS3 for the formatting.

The nav tag must contain an epub:type attribute such as epub:type="toc"

The following types are common:

  • toc - Table of contents

  • lot - List of table

  • loi - List of ilustrations

The only required nav element according to the EPUB3 specification is epub:type="toc".

This is also the most complicated since it may contain list with sublists etc.

Apple iBookStore adds another requirement that is not required by the standard, an EPUB3 formatted book to be sold on apple iBook store should contain a nav element with attribute of epub:type="landmarks" (see below)

As mentined before, since the nav elements are also machine readable, they have few constraints on what tags can appear inside them. The nav element can contain one heading (h1 - h6) only. If you need more then one heading, you can use the new hgroup tag and inside it put as many headings as you like.

After the heading (or hgroup) there should be one ol (ordered list) this is a list of what this element is about. For example if the nav tag has epub:type="lot", each list element is a link to one table.

The list elements are links to parts of the book so they should have an a element inside them. If this is only a heading of another list it may contain a span element with the name of the part.

The links in the a elements can be standard html5 links or EPUB3 CFI links (see my article: http://www.heliconbooks.com/article/epub3links)

For example:

<section epub:type="part">

    <h1>Part I</h1>

    <section epub:type="chapter">

        <h2>Chapter 1</h2> 

           ...

    </section>

    <section epub:type="chapter">

    <h2>Chapter 2</h2>

    ...

    </section>

</section>

The above example shows two lists with sublist. the second list contain an unlinked heading inside a span tag.

If you want to use this file also as readable file (declared in the spine) you should set some CSS formatting so it will look similar with your formatting on all systems.

In the above example, the unlinked heading is insided a span tag The span tag has class="navhd", this class should be defined CSS if you want to format it other then the default. It is advsied to write a CSS class and not rely on default formatting as it may be different from one reading system to another.

The list is of type ol, this means Ordered List, however you may not want to show an ordered list, so just declare in the css formatting for ol tags as list-type:none.

It is advised that navigation files will not contain elements in the body other then nav elements and the required elements inside the nav element.

 

Landmarks section

In case of files that should be compatible with apple iBook store, you must have another nav element with epub:type="landmarks". It is a good practice to add this section on all systems.

This section replaces the deprecated guide element of EPUB2. This section is a simple list (it may not contain sublists) with links to major sections of the document.

Each link must contain an epub:type attribute stating what kind of link it is. This epub:type can be one of the following:

  • cover

  • titlepage

  • frontmatter

  • bodymatter

  • backmatter

  • toc

  • loi (list of ilustrations)

  • lot (list of tables)

  • preface

  • bibliography

  • index

  • glossary

  • acknowlegments

Note that some of the elements are inside the navigation file.

If you use the navigation file as a visible file and don't want to show the landmarks section, wrap it in a div with style="display:none"

Share this post