Question

I am trying to have auto-generated table of contents in HTML.

I take inputs in the page and as I take HTML page is updated so it can show the input it take

How can I do that without using JavaScript?

Was it helpful?

Solution

You cannot generate things automatically in HTML. You would have to do the generation using a preprocessor, or a server-side tool, or with client-side JavaScript.

The best you can do in HTML to allow browsers or their add-ons to generate a table of contents is to use heading elements h1, h2 etc. consistently, according to the logical nesting level. This is what ToC generators such as the Firefox Table of Contents add-on use as data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top