Style scrollBehavior Property
Example
Add a smooth scrolling effect to a page:
document.documentElement.style.scrollBehavior = "smooth";
Try it Yourself »
Definition and Usage
The scrollBehavior property specifies whether to smoothly animate the scroll position, instead of a straight jump, when the user clicks on a link within a scrollable box.
Browser Support
| Property | |||||
|---|---|---|---|---|---|
| scrollBehavior | 61.0 | 79.0 | 36.0 | 14.0 | 48.0 |
Syntax
object.style.scrollBehavior = "auto|smooth|initial|inherit"
Property Values
| Value | Description |
|---|---|
| auto | Default. Allows a straight jump "scroll effect" between elements within the scrolling box. |
| smooth | Allows a smooth animated "scroll effect" between elements within the scrolling box. |
| initial | Sets this property to its default value. Read about initial |
| inherit | Inherits this property from its parent element. Read about inherit |
Related Pages
CSS reference: scroll-behavior property