Before/after slider

Also called image comparison slider, comparison slider, or before and after slider

A comparison control that stacks two versions of an image and lets people drag a divider to reveal more of one or the other.

What is Before/after slider?

A before/after slider places two versions of the same picture on top of each other. A vertical divider with a round handle sits in the middle, and dragging it clips the top image so more of the bottom one shows. People compare details directly instead of flipping between two pictures.

It suits photo edits, redesigns, renovations, cleaning and beauty results, image upscalers, and maps that change over time. Both images need the same size and framing, or the comparison falls apart.

Clip the top image with clip-path: inset() driven by the divider position, which is cheaper than resizing it. Let people drag anywhere on the image, keep the handle at least 44px wide for touch, and make it keyboard accessible: a native range input, or an element with role="slider" that responds to the arrow keys.

All terms

Clip-path

A CSS property that cuts an element to a shape, such as a circle, an inset rectangle, or a polygon, and hides everything outside it.

Drag gesture

Moving an element by pressing on it and sliding the pointer or finger, usually within set bounds and with a glide after release.

Mask

A CSS technique that uses an image or gradient to set how visible each part of an element is, often used to fade edges softly.

Crossfade

A transition where the old content fades out while the new content fades in at the same spot, so the two briefly overlap.