HTML Links Within a Page

The final type of HTML links is a link from one part of a web page to another part of the same web page. In order to do this we need to have two elements. First we need to create the HTML link to tell the browser what to jump to, and second we need to insert a small tag to identify the section of the page we want to jump to.

To identify a place on the page we can use an id attribute in the tag for that element. For example we might add an HTML id attribute to one of subheadings like so:

<h2 id="bananas">How nice are bananas?</h2>

Then we can create a link to jump to that part of the page like so:

<a href="#bananas">Click here to read about bananas</a>

Page links are great for times when you have a lot of information on a web page and want to give the user a way to jump to a particular section. One area where this is ideally suited is in index pages, where contents are listed alphabetically. At the top you could have a series of HTML links labeled with the letters A to Z, and when the user clicks on a letter they are taken straight to that section of the page.