# TOC doesn't work when wrapped with HTML tags

**URL:** https://meta.discourse.org/t/toc-doesnt-work-when-wrapped-with-html-tags/276325
**Category:** Support
**Tags:** disco-toc
**Created:** [March 28, 2021, 12:18am UTC](https://meta.discourse.org/t/toc-doesnt-work-when-wrapped-with-html-tags/276325 "2021-03-28T00:18:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ed\_Bobkov](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_bobkov/32/200014_2.png) [@Ed\_Bobkov](https://meta.discourse.org/u/Ed_Bobkov)
#### Post date: [March 28, 2021, 12:18am UTC](https://meta.discourse.org/t/toc-doesnt-work-when-wrapped-with-html-tags/276325/1 "2021-03-28T00:18:55Z")

</div>

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

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

```

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

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [August 23, 2023, 4:00pm UTC](https://meta.discourse.org/t/toc-doesnt-work-when-wrapped-with-html-tags/276325/2 "2023-08-23T16:00:40Z")

</div>

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:

So, it really depends on your goal.  
This guide might be of some help: [Customize posts' contents with your own styles](https://meta.discourse.org/t/customize-posts-contents-with-your-own-styles/257738)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [September 22, 2023, 4:01pm UTC](https://meta.discourse.org/t/toc-doesnt-work-when-wrapped-with-html-tags/276325/3 "2023-09-22T16:01:04Z")

</div>

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