How to create a link that goes to the top of a web page
Updated: 12/31/2022 by Computer Hope
To create a link that goes to the top of a web page, follow the steps below.
In your HTML (HyperText Markup Language) code, between the opening and closing <body> tags, add a new line where you want to place the link.
Add the top of page link using #top as the value of the href attribute, as shown below.
<a href="#top">Back to top of page</a>
For example, clicking this link takes you back to the top of the page.
Tip
All modern browsers understand the "#top" value, meaning the id or <a name="top"></a> anchor is unnecessary to return to the top. However, all other anchors need to be defined in the page.
Create a "Back to top of page" button
To create a button that goes back to the top of a web page, use the following example code.
<form> <input type="BUTTON" value="Back to top of page" onclick="window.location.href='#top'"> </form>