HOW TO: Link headings to navigation list

HOW TO: Link headings to navigation list

In the following post, I will quickly show you how to link headings to individual items in a navigation list. It’s a lot simpler than you would expect.

You would typically want to do this when you have a long article for example, and you want each item in your navigation list/content list to take the user straight to that chapter/heading.

For example, you could have the following list:

  1. Chapter 1
  2. Chapter 2
  3. Chapter 3

And then somewhere in your article, you would have the following:

Chapter 1

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Chapter 2

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ‘Content here, content here’, making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for ‘lorem ipsum’ will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

Chapter 3

There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don’t look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn’t anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.

 

Ideally, the user should be able to just click on Chapter 3 and the website would just take him there, without having to scroll all the way down to the page. This is very useful when you have tens of ‘chapters’.

 

How to do it?

First, click on Text in the top right corner, as shown in the picture above.

 

Second, identify where the code for your list is, it should look like the above.

 

Third, add an <a href=”#chapter1″></a> around each text you want to transform into a link, each Chapter in my case.

 

Fourth, go through your code and identify each heading you want to link to the navigation. Remember, based on what you chose, headings can be <h1> <h2> <h3> <h4> <h5>. Find the ones that match the name, in my case is Chapter 1 and so on.

 

 

Finally, add an id=”” property to each heading, corresponding to the item in the navigation list. For example, #chapter1 should link to the first header, using the id=”chapter1″. See the picture above.

If you preview your post now, you can test if the navigation list works correctly.

In conclusion, it’s a lot easier than most people would expect to link headings to a navigation list using really simple HTML.

One thought on “HOW TO: Link headings to navigation list

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.