Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

scroll-behavior — scrolling behavior

The scroll-behavior property controls whether navigation- or API-triggered scrolling is instant or smooth. It does not control direct user scrolling.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

scroll-behavior: auto | smooth;

scroll-behavior applies to scroll containers. The initial auto means instant scrolling; smooth means motion with browser-defined duration and timing. The property is neither inherited nor animatable.

It covers navigation, scrolling APIs, and scroll snapping operations not initiated by the user. It does not change direct gesture or wheel scrolling. On html, it controls the page viewport; setting it on body does not propagate it to that viewport. Browsers may ignore it.

In the example, overflow: auto and a constrained height create a scroll container. Calling scrollTo() with behavior: 'auto' consults the computed scroll-behavior, so it can trigger smooth motion. This differs from CSS scroll-behavior: auto. Check the final position, not a fixed animation duration.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>scroll-behavior</title>
<style>
  #panel {
    height: 120px;
    overflow: auto;
    scroll-behavior: smooth;
    border: 1px solid;
  }
  #content { height: 600px; }
</style>
<button id="go" type="button">Scroll to 240px</button>
<div id="panel" tabindex="0" aria-label="Scrollable example">
  <div id="content">Scrollable content</div>
</div>
<script>
  const panel = document.getElementById('panel');
  document.getElementById('go').addEventListener('click', () => {
    panel.scrollTo({ top: 240, behavior: 'auto' });
  });
</script>
</html>

Result

After scrolling completes without interruption: panel.scrollTop === 240. No console output.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources