# 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:** 1\
**Showing post:** 2

<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)

---

_[View the full topic](https://meta.discourse.org/t/toc-doesnt-work-when-wrapped-with-html-tags/276325)._
