Guides / Squarespace

How to Add a Before and After Image Slider to Squarespace

October 30, 2026 · 5 min read

Before-and-after photos sell remodels, landscaping, cleaning, detailing, painting, salon and clinic results better than any paragraph. Two photos side by side work, but a slider works better: visitors drag a line across one image and watch the change happen, and they keep dragging.

Squarespace doesn't have a before/after block. This guide shows a free way to build one with a Code Block, how to take photos that line up, and how to add a slider on any plan, including Basic.

Step 1: Take photos that line up

The slider only looks good if the two photos match. A wobbly "after" shot makes the whole thing look off.

  • Shoot from the same spot. Mark where you stood (a piece of tape, a landmark in the frame) and use the same height and zoom.
  • Keep the same framing. Landscape photos work best on websites. Phones: don't switch between the main and wide-angle lens.
  • Crop both to the same size before uploading, for example 1600 × 1000 pixels. Most photo apps can crop to an exact size.
  • Keep files light. Around 200–400 KB each loads quickly. Export as JPG or WebP at about 80% quality.

The slider needs a web address for each photo. On Squarespace:

  1. Edit any text block, highlight a word, click the link icon, and choose File.
  2. Upload the photo. Squarespace gives it an address like /s/kitchen-before.jpg.
  3. Remove the temporary link. Repeat for the other photo.

You can also add an Image Block, publish, then right-click the image on your live site and choose Copy image address.

The free way: a slider in a Code Block

This works on Core, Plus and Advanced plans (and legacy Business and Commerce), because it uses a little JavaScript. Add a Code Block, set it to HTML, and paste:

<div class="ba" style="position:relative;max-width:900px;aspect-ratio:16/10;overflow:hidden;border-radius:8px">
  <img src="/s/after.jpg" alt="After: new patio" style="position:absolute;inset:0;width:100%;height:100%;object-fit:cover">
  <img src="/s/before.jpg" alt="Before: bare yard" class="ba-before" style="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;clip-path:inset(0 50% 0 0)">
  <div class="ba-line" style="position:absolute;top:0;bottom:0;left:50%;width:3px;margin-left:-1px;background:#fff;pointer-events:none"></div>
  <input type="range" min="0" max="100" value="50" aria-label="Before and after"
         style="position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:ew-resize"
         oninput="var b=this.parentNode;b.querySelector('.ba-before').style.clipPath='inset(0 '+(100-this.value)+'% 0 0)';b.querySelector('.ba-line').style.left=this.value+'%'">
</div>

Replace the two src addresses with your photos, and write alt text that describes each one. Change 16/10 to match your photos' shape.

How it works: the "after" photo sits underneath, and the "before" photo sits on top, cut off at the slider's position. An invisible range input covers both, so dragging (or tapping, or using the arrow keys once it's focused) moves the cut.

What it doesn't do: there's no visible handle or labels, the line doesn't show on very light photos, and it won't run on the Basic plan. For a few sliders on one page it's a perfectly good start.

On the Basic or Personal plan

Basic plans don't run JavaScript in Code Blocks, so the free version above shows the photos but won't slide. You have two choices: upgrade to Core, or load the slider from an uploaded file through a Markdown Block, a widely used workaround. How to add custom code to Squarespace without upgrading explains the method step by step, including its caveats.

Where to use before/after sliders on Squarespace

  • Service pages: one strong pair near the top, right under the headline. It answers "can they do this?" faster than words.
  • Project pages or blog posts: one slider per project, with a short story underneath: the problem, what you did, how long it took.
  • A results gallery: three or four sliders in a two-column layout. In Fluid Engine, drag each Code Block to half width.
  • Homepage: your single best transformation. Resist using five.

Write alt text for both photos ("Before: cracked concrete patio", "After: new stone patio with fire pit"). It helps visitors using screen readers, and it helps search engines understand the images.

Tips that make sliders convert

  • Start the divider off-center (say 30%) so the first thing people see is mostly "before." The reveal is the point.
  • Label the sides if it isn't obvious which is which, especially for subtle work like cleaning or lighting.
  • Use the same slider style everywhere on your site so visitors learn it once.
  • Check it on your phone. Most visitors will drag with a thumb, and the page must still scroll when they swipe up.

The ready-made option

The Before/After Slider does everything above and handles the details for you:

  • A round handle and divider that work with mouse, touch and keyboard, and phone swiping that still scrolls the page
  • "Before" and "After" labels that move out of the divider's way, a starting position, horizontal or vertical, and a hover mode
  • Your brand colors, and a first-view "wiggle" that shows visitors it moves
  • Works on every Squarespace plan, with instructions for Code Blocks and for the Markdown Block method on Basic
  • A WordPress plugin too, if you also build WordPress sites

It's $19 once, for unlimited sites, including client sites. Try the live demo.

Want to try the settings first? The free before/after slider builder shows your choices live and writes the code for you.