How to create links to sections on the same page in HTML

Updated: 05/05/2017 by Computer Hope

AnchorTo create links to a link within the page, two HTML tags need to be used.

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

This first tag is almost the same as any other HTML tag you would use to create a link to another page. However, to create a bookmark (anchor), you must start the link with a # (pound symbol,) which represents a name statement, used in the next tag. When the user clicks on the "Top" link, the computer would then go to the name tag, if found on the same page of the link.


This next piece of code is where the link will go to on the page when the link is clicked. These are commonly referred to as bookmark and anchor. The ID attribute would be added to a tag, like a header (<H1> or <H2>) tag or a paragraph (<P>) tag. An example of what this would look like is below.

<h2 id="top">Page Header</h2>

Tip: Today, all browsers recognize top as being the top of the page. If you want the visitor to go to the very top of the page, the ID tag can be left out and the A HREF link will still work.

<a href="">Windows XP Safe Mode</a>

Finally, a link can contain a web page with a bookmark that is on that page. In the above example, this code would create a link to our Safe Mode page and automatically move down to the Windows XP Safe Mode section on that page.


In this first example, clicking on the "Top" link will scroll your browser to the top of this page.


In the next example, clicking on the "Windows XP Safe Mode" link will first open our Safe Mode page and then automatically scroll down to the Windows 2000 Safe Mode steps.

Windows XP Safe Mode

Additional information