Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 5.6 — Overflow and Scrolling
CSS · Example 3 of 3

scrollbar-gutter and smooth scrolling

On Windows or Linux with classic scrollbars, the second panel keeps an empty strip where a scrollbar would go. With overlay scrollbars (macOS, phones) both look the same.

When content is bigger than its box, overflow decides what happens: spill out (visible), cut off (hidden, clip), or scroll (scroll, auto); scrollbar-gutter and scroll-behavior polish how scrolling looks and feels.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Make a .code box 200px tall that scrolls vertically only when its content is taller. Fill it with 400px of content and log scrollHeight and clientHeight (no padding or border on the box).

02

Show that a overflow: clip box can't be scrolled by script, but an overflow: hidden one can. Log both scrollTop values after setting them to 40.

Explain it without notes

01

Explain the five overflow values and when you'd use each.

02

What is a scroll container, and what side effects does creating one have?

03

Why does overflow-x: hidden alone often add a vertical scrollbar?

04

What problem does scrollbar-gutter: stable solve?

scrollbar-gutter and smooth scrolling

Preview

Press Run to see the page.

Console

Nothing logged yet.