CSS scroll-behavior Property

❮ Previous Reference Next ❯

Example

html {
  scroll-behavior: smooth;
}





1 2 3

1

2

3


Meaning

The scroll-behavior property sets the behavior for a scrolling box when scrolling is triggered by the navigation or CSSOM scrolling APIs.

Note: That any other scrolls, such as those performed by the user, are not affected by this property.

When this property is specified on the root element, it applies to the viewport instead. This property specified on the <body> element will not propagate to the viewport.

Default value:auto
Inherited:No
Animatable:No
Version:CSSOM View Module (Working Draft)
JavaScript syntax:
object.style.scrollBehavior="auto|smooth|initial|inherit|revert|revert-layer|unset";



Standard Syntax

scroll-behavior: auto|smooth|initial|inherit|revert|revert-layer|unset;



Browser Support

The numbers in the table specify the first browser version that fully supports the property.




Status







Property Values

The following table describes the values of this property.

Value Description
auto This is default value. The scrolling box scrolls instantly.
smooth The scrolling box scrolls in a smooth fashion using a user-agent-defined timing function over a user-agent-defined period of time.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-delay property.
revert Reverts the cascaded value of the property from its current value to the value the property
revert-layer Rollback styles to the ones specified in previous cascade layers.
unset Resets a property to its inherited value if the property naturally inherits from its parent, and to its initial value if not.



Default CSS Property Values

selectors {
  scroll-behavior: auto;
}
❮ Previous Reference Next ❯