Create “Back to Top” button in Squarespace

In this post, we will learn how to create “Back to top” button in Squarespace.


  • Only appear when scroll down
  • Disappear when scrolled up near the top of the site

1. Add HTML & Script to Footer

Go to Settings > Advanced > Code Injection > Footer.

Then insert the following code

<button onclick="topFunction()" id="kltop" title="Go to top">Top</button>
    //Get the button:
mybutton = document.getElementById("kltop");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
  if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { = "block";
  } else { = "none";

2. Add CSS to Custom CSS

Go to Design

Next, click Custom CSS

and insert the following CSS code

#kltop {
  display: none; /* Hidden by default */
  position: fixed; /* Fixed/sticky position */
  bottom: 20px; /* Place the button at the bottom of the page */
  right: 30px; /* Place the button 30px from the right */
  z-index: 99; /* Make sure it does not overlap */
  border: none; /* Remove borders */
  outline: none; /* Remove outline */
  background-color: red; /* Set a background color */
  color: white; /* Text color */
  cursor: pointer; /* Add a mouse pointer on hover */
  padding: 15px; /* Some padding */
  border-radius: 10px; /* Rounded corners */
  font-size: 18px; /* Increase font size */

#kltop:hover {
  background-color: #555; /* Add a dark-grey background on hover */

3. Results

Reference: W3Schools

Done. If you have any question, just comment below.

Share this post:

If you have any questions, just fill in form below

Each FREE/PAID option will have different priorities.
If your site is private or in trial, just setup password and share url. See how to:
Posted in