Scrolling is the movement of webpage content vertically or horizontally when the content exceeds the visible area.
Scrolling is one of the most important parts of modern web design and user experience.
It allows users to explore more content smoothly without changing pages.
Vertical scrolling is the default webpage scrolling behavior.
Users scroll up and down to view content.
[code theme="dark"] body{ overflow-y:auto; } [/code]Most websites use vertical scrolling for content navigation.
Horizontal scrolling moves content left and right.
It is commonly used for sliders, galleries, and modern storytelling sections.
[code theme="dark"] .container{ overflow-x:auto; white-space:nowrap; } [/code]The overflow property controls scrolling behavior.
| Value | Description |
|---|---|
| visible | Default overflow behavior |
| hidden | Hides extra content |
| scroll | Always shows scrollbar |
| auto | Shows scrollbar only when needed |
Smooth scrolling creates a modern animated scrolling experience.
[code theme="dark"] html{ scroll-behavior:smooth; } [/code]This makes anchor link navigation feel smoother and more professional.
Container scrolling happens inside a specific element instead of the entire page.
[code theme="dark"] .container{ height:400px; overflow:auto; } [/code]This is commonly used in:
Scroll snapping automatically aligns content while scrolling.
[code theme="dark"] .container{ scroll-snap-type:y mandatory; } .section{ scroll-snap-align:start; } [/code]It creates app-like scrolling behavior.
Developers sometimes hide scrollbars for cleaner UI designs.
[code theme="dark"] .container::-webkit-scrollbar{ display:none; } [/code]This technique is commonly used in modern sliders and galleries.
Scrollbars can also be customized using CSS.
[code theme="dark"] ::-webkit-scrollbar{ width:10px; } ::-webkit-scrollbar-thumb{ background:#555; border-radius:20px; } [/code]Modern CSS allows animations to run based on scrolling.
[code theme="dark"] .box{ animation:fade linear; animation-timeline:view(); } [/code]The animation progresses while the user scrolls.