Website Building » Squarespace » How Do I Make a Smooth Scroll in Squarespace?

How Do I Make a Smooth Scroll in Squarespace?

Last updated on December 29, 2022 @ 7:26 pm

There are many ways to style text on a web page, but the most common methods are to use the ‘<b>‘ and ‘<u>‘ tags. These tags will make the text bold and underlined, respectively. Other tags that are commonly used to style text include the ‘<i>‘ tag (for italics), the ‘<strong>‘ tag (for bold), and the ‘<strong>’ tag (for emphasis).

To make a smooth scroll in Squarespace, you’ll need to add some code to your site. The code for a smooth scroll is as follows:

<script type="text/javascript">
$(function() {
  $('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.replace(/^\//,'') && 
    location.hostname == this.hostname) {

      var Target = $(this.hash);
      Target = Target.length ? Target : $('[name=' + this.hash.slice(1) +']');
      if (Target.length) {
        $('html,body').animate({
          scrollTop: Target.offset().top
        }, 1000);
        return false;
      }
    }
  });
});
</script>

This code will add a smooth scroll to any link on your site that has the “#” character in it. For example, if you have a link that says “Scroll to Top”, the link would look like this:

<a href="#">Scroll to Top</a>

When someone clicks on that link, they will be smoothly scrolled to the top of the page.

PRO TIP: Warning: The following article contains instructions on how to make a smooth scroll in Squarespace. Please use caution when following these instructions, as smooth scrolling can cause problems with some browsers and may not work as intended.
Morgan Bash

Morgan Bash

Technology enthusiast and Co-Founder of Women Coders SF.