Creating Internal Links

To create an internal link in HTML, use the a tag's href attribute to point to the id of the target element. You do this by prefixing the ID with a hash symbol (#).

Internal links, also known as "anchor links," allow users to jump to specific parts of a page. This can be quite handy for long articles or FAQ pages. You can use the internal link technique to create a table of contents at the top of the page.

The Two Steps

To create an internal link, you need two things: an ID on the target element and a Link that points to that ID.

1. Create the Target ID

First, add an id attribute to the element you want to jump to. The ID must be unique on the page.

2. Create the Link

Next, create a link that uses the hash symbol followed by that ID in its href attribute.

Tip: Case Sensitivity

While IDs in HTML are technically case-insensitive in many contexts, it's a best practice to always use lowercase for your IDs and links (e.g., #my-id instead of #My-ID) to avoid confusion and potential issues.

Creating a "Back to Top" Link

A "Back to Top" link is just an internal link that points to the top of the page. You can point it to an ID at the top, or simply use #:

Full Example

Here is a working example of internal links in a single page:

View Example in New Window