“CSS scroll-snap: Create Full-Screen Vertical Scrolling Pages”
With CSS scroll-snap, you can make a page where sections snap into place one full screen at a time as you scroll vertically. It works for full-screen scrolling pages (also called full-page scrolling), such as landing pages that introduce products or services one screen at a time, or pages that show one slide at a time. No JavaScript library is needed. Set scroll-snap-type: y mandatory on the html element, and set height: 100vh and scroll-snap-align: start on each section.
The test environment was Ubuntu 24.04, Node.js 22.23.4, Playwright 1.63.0, and headless Chromium 153. I opened the page at 360px wide and 640px high. Finger swipes were reproduced with Chrome DevTools Protocol touch events, and mouse wheel input with Playwright's mouse.wheel(). I recorded the stopping position (scrollTop). I did not test Firefox, Safari, real smartphones, behavior when the address bar appears or hides, trackpads, or real mouse operation.

- 1. Add scroll-snap-type to html and scroll-snap-align to sections
- 2. Putting it on body does not snap
- 3. Where it stops after release, and which section it lands on
- 4. Switch one screen at a time even after a hard flick
- 5. Keyboard, mouse wheel, and in-page links also switch screens
- 6. Sections taller than the screen can still be read to the end
- 7. When the screen height changes, snap again to the visible section
- 8. Browser support
Add scroll-snap-type to html and scroll-snap-align to sections
The HTML is simply a set of sections placed one after another.
<main>
<section class="screen" id="s1"><h2>1ページ目</h2><p>上へスワイプすると、次のセクションが画面いっぱいに表示されます。</p></section>
<section class="screen" id="s2"><h2>2ページ目</h2><p>途中で指を離しても、セクションの上端で止まります。</p></section>
<!-- Pages 3 to 5 follow the same pattern -->
</main>
The CSS is as follows.
/* Stop the page scroll at the top edge of each section */
html {
scroll-snap-type: y mandatory;
}
body {
margin: 0;
color: #1f2a30;
}
/* Sections that are one screen tall */
.screen {
box-sizing: border-box;
height: 100vh;
padding: 24px;
display: flex;
flex-direction: column;
justify-content: center;
scroll-snap-align: start;
scroll-snap-stop: always;
}
.screen:nth-child(odd) {
background: #eefafd;
}
.screen h2 {
margin: 0 0 12px;
font-size: 28px;
color: #067a98;
}
.screen p {
margin: 0;
font-size: 16px;
line-height: 1.7;
}
Four properties control the stopping behavior:
scroll-snap-type: y mandatoryonhtml: makes vertical scrolling always settle at one of the snap positionsheight: 100vhon.screen: makes each section the height of the screenscroll-snap-align: starton.screen: aligns the top edge of each section to a snap positionscroll-snap-stop: alwayson.screen: prevents sections from being skipped even after a strong flick (explained in a later section)
According to MDN's page on scroll-snap-type, mandatory always snaps to a snap position when scrolling is not in progress, while proximity lets the browser decide whether to snap. In the test environment (640px high), each section is 640px tall, and there are five snap positions: 0, 640, 1280, 1920, and 2560.
Putting it on body does not snap
scroll-snap-type goes on html, not body. I also tested a version with nothing on html and scroll-snap-type: y mandatory on body. It stopped exactly where I released my finger, the same as a version without snapping.
The CSS Scroll Snap specification says that a scroll-snap-type set on the root element (html) is used for scrolling the whole page. Unlike overflow, a value set on body does not propagate to the whole page.
Where it stops after release, and which section it lands on
I swiped up from page 1, released my finger, and compared the scrollTop where it stopped. The swipe was split into 12 steps, 40ms apart.
| Distance swiped | y mandatory (the CSS in this article) |
y proximity |
No snap |
|---|---|---|---|
| 100px | 0 (page 1) | 0 (page 1) | 85 |
| 250px | 0 (page 1) | 235 | 235 |
| 400px | 640 (page 2) | 385 | 385 |
With mandatory, it never stopped partway through a section. At 250px it returned to page 1, and at 400px it moved on to page 2. The stop position is whichever of 0 and 640 is closer. With proximity, only the 100px swipe returned to page 1; at 250px and 400px it stopped where the finger was released. Because proximity can stop partway through a section, mandatory is the better fit for pages that show one screen at a time.
When I used a script to jump to a position in the middle of a section, mandatory still snapped to the nearest section. scrollTo({ top: 400 }) went to 640, and scrollTo({ top: 1000 }) went to 1280.
Switch one screen at a time even after a hard flick
A strong flick can carry the page two screens ahead. To make one operation move exactly one screen, add scroll-snap-stop: always to the sections. According to MDN's page on scroll-snap-stop, always prevents scrolling from passing over a snap position. The initial value, normal, allows passing over.
From page 1, I swiped up in three steps, 16ms apart, then released. I repeated this 20 times for each setting.
| Distance swiped | always (the CSS in this article) |
normal |
|---|---|---|
| 400px | Stopped on page 2 in all 20 | Stopped on page 2 in 14; reached page 3 in 6 |
| 450px | Stopped on page 2 in 17; reached page 3 in 3 | Reached page 3 in all 20 |
With normal, a 450px swipe reached page 3 in all 20 attempts. With always, most attempts stopped on page 2. However, in the test Chromium, always still reached page 3 in 3 of the 20 attempts with a 450px swipe. So this does not guarantee one screen per operation in every case.
Keyboard, mouse wheel, and in-page links also switch screens
From page 1, I pressed one key at a time and recorded the stop position.
| Key pressed | y mandatory |
No snap |
|---|---|---|
| PageDown | 640 | 560 |
| PageDown | 1280 | 1120 |
| Space | 1920 | 1680 |
| ↓ | 2560 | 1720 |
| ↓ | 2560 | 1760 |
| PageUp | 1920 | 1200 |
| Shift+Space | 1280 | 640 |
| End | 2560 | 2560 |
| Home | 0 | 0 |
Without snap, PageDown moves 560px, a bit less than one screen, and the ↓ key moves 40px at a time. With mandatory, PageDown, PageUp, Space, and Shift+Space each moved exactly one screen. A single press of the ↓ key also moved to the next section.
For the mouse wheel, I scrolled down from page 1 using Playwright's mouse.wheel(). With a delta (deltaY) of 100 or 300, the page stayed on page 1. With 330 and 400, it moved to page 2. In this range, like finger swiping, it stopped at whichever of 0 and 640 was closer. A single operation with deltaY of 1000 reached page 3 (1280), and one with 2000 reached page 4 (1920). Even with scroll-snap-stop: always, a large wheel operation can skip sections.
In-page links also work. Pressing <a href="#s4"> set scrollTop to 1920, the top edge of page 4. Giving each section an id lets links such as a table of contents jump to the section you want.
Sections taller than the screen can still be read to the end
If the content does not fit on the screen, use min-height: 100vh instead of height: 100vh so the section grows with its content. MDN's basic concepts page for scroll snap warns that when a child's content overflows its parent, the overflowing part cannot be reached by scrolling, so mandatory should not be used in that case.
On the other hand, the specification section on snap areas larger than the scrollport says that while a section is larger than the screen and covers it entirely, the page may stop at any position. So I stretched only page 3 to 1527px high and tested with y mandatory still in place. Page 3's top edge is at 1280, the position where its bottom edge lines up with the bottom of the screen is 2167, and page 4's top edge is at 2807.
I swiped up 200px at a time, five times, from the top edge of page 3. The stop positions were 1465, 1650, 1835, 2020, and 2167. Within page 3, it stopped where the finger was released and was not returned to the section's top edge. Sending it to 1500 or 1900 with scrollTo() also left it there.
Once it reached the bottom of page 3 (2167), it became hard to move further. Even after an additional 300px swipe it stayed at 2167, and a 400px swipe moved it to page 4 (2807). With the keyboard, within page 3 the ↓ key moved 40px and PageDown moved 560px. It stopped once at the bottom edge (2167), and the next PageDown moved to page 4.
In the test Chromium, long sections stretched with min-height could still be read to the end with mandatory. The hidden parts that MDN warns about did not appear.
When the screen height changes, snap again to the visible section
I stopped at page 3 (1280), then changed the screen height from 640px to 500px. Each section became 500px tall, so page 3's top edge moved to 1000. With mandatory, scrollTop also became 1000, keeping page 3's top edge aligned with the top of the screen. Without snap, it stayed at 1280, showing the middle of page 3.
The specification section on re-snapping after layout changes says that if snapping was in effect before the layout changed, the browser snaps again to the same element after the change.
For the vh unit used for the section height, MDN's <length> page explains that vh is the same as lvh (large viewport). While the browser toolbars are visible, content may be hidden in the full-screen layout. There are also svh, which matches the small viewport, and dvh, which matches the current size.
Browser support
According to the compatibility data in @mdn/browser-compat-data 8.1.8, scroll-snap-type and scroll-snap-align are supported from Chrome 69, Edge 79, and Safari 11 (iOS Safari also 11). Firefox supports scroll-snap-align from 68 and scroll-snap-type from 99 (partial support from 68). scroll-snap-stop is supported from Chrome 75, Edge 79, Firefox 103, and Safari 15.





