Creating table of contents in html
This can indeed be done with pure CSS:
ol {
counter-reset: item;
}
li {
display: block;
}
li:before {
content: counters(item, ".")" ";
counter-increment: item;
}
Same example as a fiddle.
There's quite a number of jQuery plugins to generate a table of contents.
Look at this one for starters
Another one here, with ordered lists
Have you seen this post: Number nested ordered lists in HTML
I don't think it can be done without using JS.