A Beginner's Guide to Adding Internal Links in HTML

Using the ID attribute tag to create page bookmarks

A business man working at office

Kohei Hara / Getty Images

ID attribute tags allow site visitors to click a link and be transported instantly to a bookmarked location within the same document. A typical application is a list of included topics at the top of an article, similar to a table of contents. 

HTML 4 and earlier versions used the name attribute to form internal links. HTML 5 doesn't support the name attribute and uses the ID attribute instead.

This approach entails naming the area to which you'd like to link and then creating a link to it using an ID attribute. Here's how:

  1. Decide which section of the page you'd like to link to. As an example, let's say you want to link to the last paragraph at the bottom of a page.

  2. Name the appropriate section by adding an ID attribute to the tag. In this example, it's named lastparagraph, like so:

    <p="lastparagraph">The last paragraph</p>
  3. Create the internal link just as you would for the more common external link, but replace the URL with the ID of the last paragraph:

    <a href="#lastparagraph">The link</a>
  4. Test your link.

    W3Schools offers a free online code "sandbox" where you can test your HTML.