More Web Design Tutorials

Basic HTML – Creating a Bookmark (Internal Hyperlink) Part II

February 25, 2011

In addition to links that lead away from the current page, there are also ‘internal’ links – hyperlinks that take one to a specific spot on the current page. Those spots are called ‘bookmarks’ and the most frequent bookmark that’s being linked to is ‘go to top’.

In order to get such a link to work, first we have to create the bookmark. That’s done by adding id=”bookmark” to an element. I’m just using the word ‘bookmark’ as a placeholder – ideally, we’d use whatever makes sense. For example:

<div id="top">

This creates the bookmark. Now we need a hyperlink to take us there.

<a href="#top">Back to Top</a>

I want to mention that this way of bookmarking is a more current method – the old way to create the bookmark looked like this:

<a name="top">Top of Page</a>

The way to link to it is the same. This old way isn’t wrong, just outdated. Best to stick to the id-method.

Here is a page with several bookmarks. Be sure to right-click it and chose ‘View Source’ so you can see how the bookmarks were placed and how the links to them are written: Bookmark Tutorial Page