How to Create a Website Back Button

JavaScript Back Button Code for an HTML Page

Back button

Ironbrother/Public Domain

A back button built-in to a browser, of course, lets you move backward to return to the previous page you were on. You can also make one that rests within the web page itself, using some JavaScript code.

This button, when clicked, will take the reader back to the page they were on before they came to the current page with the button. It functions just like the back button in web browsers.

Basic Back Button Code

The basic code for a back button link is very simple:

All you have to do with this back button code is copy and paste it wherever you want the "Go Back" link to be found on your page. You can also change the text for it to read as something else.

Back Button With an Image

If you'd rather not have a plain text back button, you can always add an image to it for some extra uniqueness.

The image replaces the part of the back button code where you see the words "Go Back" in the example above. This works by deleting that text and replacing it with code that will show an image in place of that text.

For this, you need the URL of the image that the back button should use, like this:

Tip: Imgur is one place you can upload your button image if it doesn't already exist online.

Then, you want to insert that link directly into the INSERT section you see here (be sure to keep the quotes intact):

Our example would look like this: