Below is the coding for a linkable table of contents.
OPTION ONE: LINKS TO PAGES IN YOUR eBOOK
If you split your chapters into individual HTML pages, then your TOC would appear like this:
<p><a id="toc"/></p> <p>Table of Contents</p> <p><a href="../Text/content.xhtml">Chapter 1</a></p> <p><a href="../Text/chapter2.xhtml">Chapter 2</a></p> <p><a href="../Text/chapter3.xhtml">Chapter 3</a></p> <p><a href="../Text/ack.xhtml">Acknowledgements</a></p> <p><a href="../Text/author.xhtml">About the Author</a></p>
OPTION TWO: LINKS ANCHOR LOCATIONS ON THE SAME PAGE (ONE HTML PAGE)
If you are working from one long HTML “Page” and need to create a TOC that links to the sections, then you need to create anchors and your TOC would appear like this:
Where the anchor name is preceded by a hash tag (#) such as #chapter1.
<p><a id="toc"/></p> <p>Table of Contents</p> <p><a href="#chapter1">Chapter 1</a></p> <p><a href="#chapter3">Chapter 2</a></p> <p><a href="#chapter4">Chapter 3</a></p> <p><a href="#ack">Acknowledgements</a></p> <p><a href="#author">About the Author</a></p>
ANCHORS:
You would need to create anchors for each chapter/section. This would appear like this:
<h1 id=”chapter1″>Chapter1</h1>
where “id” is the anchor name. Anchors and links must match.
Back to TOC
It isn’t necessary to create a back to TOC as most e-readers have the option built-in, however if you wish to add it, then you would create
<a href=”#toc>Back to TOC</a>
and place this where you need for every chapter/section, so long as you have the “id” for the toc AS “toc”