How to create html table of contents

How to create html table of contents: TOC code created using post headings, html order list tag and css style. You can easily create by given steps.

Creating html table of contents is simple. Before creating TOC, first you have to decide heading depth, you want to include in list. Suggestion is to include all heading in your list.

Process:
  • List out all H2(top level) headings from blog post.
  • Create ordered list using top level heading.
  • Now list out H3 sub heading list which exist under first H2 content.
  • If some H2 content not have H3 than ignore it.
  • Create H3 heading ordered list and add in related H2 TOC entry.
  • Now, you can follow same process for H4 sub headings
Your final html after above process is like below:
<ol>
    <li>
        Heading level 1 entry 1
        <ol>
        <li>Heading level 2 entry 1</li>
        </ol>
    </li>
</ol>

No comments: