Mastering Table of Contents: The Perfect Formatting Guide

Johnny Jul 09, 2026

Properly formatting a Table of Contents (ToC) is crucial for enhancing the readability and navigability of your document. A well-structured ToC helps readers quickly find the information they need, making your content more accessible and user-friendly. Here's a comprehensive guide on how to format a Table of Contents correctly.

Add A Table of Contents To Any Book or Ebook
Add A Table of Contents To Any Book or Ebook

Before diving into the formatting aspects, it's essential to understand that a ToC should reflect the hierarchical structure of your document. It typically includes the main headings (usually at the chapter level) and their corresponding subheadings. Let's explore how to create an effective ToC using HTML tags.

How to Create a Table of Contents in Word
How to Create a Table of Contents in Word

Understanding the Hierarchy

ToC hierarchy is based on the heading levels in your document. The most common heading levels are H1 (main headings) and H2, H3, etc. (subheadings). In an HTML document, these correspond to the <h1>, <h2>, <h3> tags, and so on. Understanding this hierarchy is key to creating a well-structured ToC.

the table of content is shown with numbers and names for each player in their team
the table of content is shown with numbers and names for each player in their team

For instance, if your document has chapters (H1) and sections (H2) within those chapters, your ToC should reflect this structure. In this case, the ToC will list the chapters (H1) as the main items, with their respective sections (H2) as indented sub-items.

Formatting Main Headings (H1)

a poster with the names and numbers for an event in front of a cityscape
a poster with the names and numbers for an event in front of a cityscape

In your document, use the <h1> tag to denote the main headings, typically representing chapters or sections. For example:

<h1>Chapter 1: Introduction</h1>

In the ToC, these will appear as the main list items, with their corresponding page numbers.

How To Create A Table Of Contents In Microsoft Word
How To Create A Table Of Contents In Microsoft Word

Formatting Subheadings (H2, H3, etc.)

Use <h2>, <h3>, etc., to denote subheadings within your main headings. For instance:

<h2>Section 1.1: Purpose</h2>

How to Create a Table of Contents for Your Book - Write Nonfiction NOW!
How to Create a Table of Contents for Your Book - Write Nonfiction NOW!

In the ToC, these will appear as indented sub-items under their respective main headings. For example:

  • Chapter 1: Introduction
    • Section 1.1: Purpose
    • Section 1.2: Scope
a white and black menu with the words content on it
a white and black menu with the words content on it
the table of contents is shown in this collage
the table of contents is shown in this collage
the table of contents page is shown in black and white, with an image of a cat on it
the table of contents page is shown in black and white, with an image of a cat on it
the table of contents is shown in black and white
the table of contents is shown in black and white
9 Essential Poetry Manuscript Format Tips to Get Published | Writers.com
9 Essential Poetry Manuscript Format Tips to Get Published | Writers.com
Client Challenge
Client Challenge
a woman standing next to a white sign with the words table of contents on it
a woman standing next to a white sign with the words table of contents on it
Magazine personnalisé
Magazine personnalisé
Table of Content Page
Table of Content Page
20+ Table of Contents Template | Mous Syusa
20+ Table of Contents Template | Mous Syusa
a woman with curly hair smiling and wearing a t - shirt that says how to create a table of contents in google docs
a woman with curly hair smiling and wearing a t - shirt that says how to create a table of contents in google docs
the table of contents is shown in this printable bookmark for students to use
the table of contents is shown in this printable bookmark for students to use
Table of Contents Treasure Hunt | Activity | Education.com
Table of Contents Treasure Hunt | Activity | Education.com
Microsoft Word Table Of Contents Template
Microsoft Word Table Of Contents Template
Word Tab Index Page - 7 Free PDF Printables | Printablee
Word Tab Index Page - 7 Free PDF Printables | Printablee
Purple Simple Minimalist Table of Contents - Templates by Canva
Purple Simple Minimalist Table of Contents - Templates by Canva
a computer screen with the words table of contents in front of it, and an image of
a computer screen with the words table of contents in front of it, and an image of
Table of Contents
Table of Contents
Modern Table of Contents
Modern Table of Contents
How to Make a Table of Contents, With Examples
How to Make a Table of Contents, With Examples

Creating the Table of Contents

Now that you understand the hierarchy, let's create the ToC itself. You can use an unordered list (<ul>) for the main headings and nested lists for the subheadings. Here's an example:

<ul> <li><a href="#chapter1">Chapter 1: Introduction</a> <ul> <li><a href="#section11">Section 1.1: Purpose</a></li> <li><a href="#section12">Section 1.2: Scope</a></li> </ul> </li> <li><a href="#chapter2">Chapter 2: Methods</a> <ul> <li><a href="#section21">Section 2.1: Experimental Design</a></li> <li><a href="#section22">Section 2.2: Data Analysis</a></li> </ul> </li> </ul>

In this example, each list item represents a main heading (Chapter), with nested lists representing their respective subheadings (Sections). The <a> tags are used to create clickable links that will take readers to the corresponding headings in the document.

Adding Page Numbers

To include page numbers in your ToC, you can use the <a> tag's href attribute to link to the corresponding heading in your document. For example:

<li><a href="#chapter1">Chapter 1: Introduction (Page 1)</a></li>

In this case, "Page 1" is the page number where the "Chapter 1" heading appears in your document.

Styling the Table of Contents

To make your ToC more visually appealing, you can use CSS to style it. For instance, you can change the font size, color, and style, or add borders and backgrounds. Here's a simple example:

<style> ul.toc { list-style-type: none; padding: 0; } ul.toc li { font-size: 1.2em; margin-bottom: 0.5em; } ul.toc li a { text-decoration: none; color: #333; } </style>

In this example, the ToC has no bullet points (list-style-type: none), a larger font size (font-size: 1.2em), and no underlines for the links (text-decoration: none).

In conclusion, properly formatting a Table of Contents involves understanding the document's hierarchy, using the correct HTML tags for headings, creating a structured list for the ToC, and styling it for better readability. A well-formatted ToC significantly enhances the user experience, making your content more accessible and engaging.