Style scrollBehavior attribute

Definition and Usage

scrollBehavior The attribute specifies whether there is a smooth animation effect when the user clicks on a link within a scrollable box, instead of jumping directly.

See also:

CSS Reference Manual:scroll-behavior attribute

Example

Add a smooth scrolling effect to the page:

document.documentElement.style.scrollBehavior = "smooth";

Try it yourself

Syntax

object.style.scrollBehavior = "auto|smooth|initial|inherit"

Attribute value

Value Description
auto Default. Allows direct jumps between elements within the scrollable box.
smooth Smooth animation effect between elements within the scrollable box.
initial Set this attribute to its default value. See also initial
inherit This attribute is inherited from its parent element. See also inherit

Browser support

The numbers in the table indicate the first browser version that fully supports this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
61.0 79.0 36.0 14.0 48.0