TOC doesn't work when wrapped with HTML tags

Another question. I added extra div to the post. Now it looks like this:

<div data-theme-toc="true"> </div>
<div data-theme-profile="manual">
## Chapter 1
## Chapter 2

But the TOC is not visible in this case. How can it be fixed?


I don’t know your purpose, but you can target the titles using several methods.

  1. Use HTML title tags with data-attributes, such as <h1 data-header-1>Chapter 1</h1> so you can target [data-header-1] with CSS.

  2. Insert empty div with a data-attribute aty some point, that you can use to target following elements. For example, putting <div data-next-titles></div> after the 2nd title and adding this CSS:

    [data-next-titles] ~ .d-toc-post-heading {
        color: pink;

    Will make this:

So, it really depends on your goal.
This guide might be of some help: Customize posts' contents with your own styles


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.