How to Dynamically Generate a Table of Contents
One of the great things about structured content like HTML is that you can manipulate the structure to generate little extras like a list of links or a table of contents. With long form writing making something of a comeback in the last year or so, we’ve started to notice more tables of contents on the web, offering a quick way to jump down the page to the sections you want to read. Check out developer Steve Losh’s blog for a great example of a table of contents.
Here’s Coyier’s take on the benefits of using a dynamically generated table of contents:
For all the code, and a detailed explanation of what’s going on, head on over to CSS-Tricks.