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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top