How to Make Headings Appear in Table of Contents

Johnny Jul 09, 2026

Ever found yourself wishing your long, content-rich documents were easier to navigate? One way to achieve this is by creating a table of contents (TOC) that allows readers to quickly jump to specific sections. But what if you want certain headings to appear in your TOC, while others don't? Here's a step-by-step guide on how to make specific headings appear in your table of contents.

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

Before we dive in, let's understand that by default, all heading tags (h1 through h6) are included in the TOC. However, there are cases when you might want to exclude certain headings. For instance, you might have a heading that serves as a subheading within a larger section, and you don't want it to appear in the TOC, creating confusion for your readers.

the table of contents is shown in this info sheet, which shows how to use it
the table of contents is shown in this info sheet, which shows how to use it

Using CSS to Control TOC Appearance

To control which headings appear in your TOC, you can use CSS. The :not() pseudo-class is particularly useful here. It selects elements that do not match a list of selectors. Here's how you can use it to exclude a specific heading from the TOC:

How to Create a Table of Contents in Word and Update it? | IT4nextgen
How to Create a Table of Contents in Word and Update it? | IT4nextgen

<style> h2:not(.no-toc) { page-break-before: always; } </style>

Applying the no-toc Class

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

In the above CSS, we've used the :not() pseudo-class to select all h2 elements that don't have the class "no-toc". We've then set the "page-break-before" property to "always", which tells the browser to insert a page break before these headings. This effectively removes them from the TOC.

To apply this, you would add the "no-toc" class to the h2 elements you want to exclude from the TOC:

<h2 class="no-toc">This heading will not appear in the TOC</h2>

Client Challenge
Client Challenge

Using the TOC CSS Class

If you want to include a heading in the TOC, you can use the "toc" class. This is a default class that WordPress adds to all headings. However, if you're not using WordPress or if you've removed this class, you can add it back:

<h2 class="toc">This heading will appear in the TOC</h2>

Stopping the TOC from Appearing in the Navigation Pane
Stopping the TOC from Appearing in the Navigation Pane

Manually Creating a TOC

If you're not using an automated TOC plugin or feature, you can create one manually using HTML and CSS. This gives you complete control over which headings appear in the TOC.

How to make a table of contents in word
How to make a table of contents in word
How to Make Table of Contents in Word
How to Make Table of Contents in Word
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
How to insert a table of contents manually in Word
How to insert a table of contents manually in Word
Table of Contents Plus
Table of Contents Plus
How to Build a Table of Contents in InDesign
How to Build a Table of Contents in InDesign
How to add a table of contents to a Word 2016 document - gHacks Tech News
How to add a table of contents to a Word 2016 document - gHacks Tech News
an open book showing the contents and numbers of items for sale in store or rental
an open book showing the contents and numbers of items for sale in store or rental
Table of Contents and Index: Two ways to help readers find their way
Table of Contents and Index: Two ways to help readers find their way
Here's the Easy Way to Insert a Table of Contents in Microsoft Word
Here's the Easy Way to Insert a Table of Contents in Microsoft Word
How To Make Clickable Table of Contents in Word, 4 Easy Ways
How To Make Clickable Table of Contents in Word, 4 Easy Ways
a table of contents is shown in an open notebook on a desk with markers and pencils
a table of contents is shown in an open notebook on a desk with markers and pencils
Generate a Table of Contents Automatically.
Generate a Table of Contents Automatically.
How to Make a Table of Contents in Microsoft Word
How to Make a Table of Contents in Microsoft Word
Post by @advancetotraining · 1 image
Post by @advancetotraining · 1 image
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
How to Make a Table of Contents, With Examples
How to Make a Table of Contents, With Examples
How To Create a Clickable Table of Contents in Microsoft Word
How To Create a Clickable Table of Contents in Microsoft Word
How to Create a Table of Contents in InDesign
How to Create a Table of Contents in InDesign
Intro to HD workbook
Intro to HD workbook

Here's a simple example:

<nav> <h2>Table of Contents</h2> <ul> <li><a href="#heading1">Heading 1</a></li> <li><a href="#heading2">Heading 2</a></li> <li><a href="#heading3">Heading 3</a></li> </ul> </nav>

Linking to Headings

In the above example, we've used the "id" attribute to link to specific headings. This is a simple and effective way to create a TOC. Here's how you would apply it:

<h2 id="heading1">This heading will appear in the TOC</h2>

Remember to use unique IDs for each heading you want to link to.

In conclusion, making specific headings appear in your table of contents is a great way to improve the navigation of your long documents. Whether you're using CSS to exclude headings or manually creating a TOC, the key is to provide a clear and intuitive path for your readers. So, go ahead and experiment with these methods to create a TOC that works best for your content.