CSS | scroll-behavior Property
This property is used for smooth animation of scroll position instead of a scroll jump. When the user clicks on links it smoothly performs its operation. It is used to visit one link to another link within a scrollable box.
Syntax:
scroll-behavior: auto|smooth|initial|inherit;
Property:
- smooth: This property is used to specify the animation effect of scroll between the elements within the scrollable box.
Syntax:
scroll-behavior:smooth;
Example:
<!DOCTYPE html><html><head><title>CSS | scroll-behavior Property</title><style>.g4g {font-size:40px;font-weight:bold;color:green;text-align:center;}html {scroll-behavior: smooth;}#geeks {height: 400px;background-color: coral;}#gfg {height: 400px;background-color: lightblue;}a {text-decoration:none;font-size:25px;font-weight:bold;}</style></head><body><divclass="g4g">GeeksforGeeks</div><h2style="text-align:center;">Scroll-behaviour:smooth;</h2><divclass="main"id="geeks"><ahref="#gfg">geeksforgeeks</p></div><divclass="main"id="gfg"><ahref="#geeks">GEEKSFORGEEKS</a><pstyle="color:green;">A computer science portal for geeks.</h3></div></body></html>chevron_rightfilter_noneOutput:

- auto: It is used to specify the straight jump scroll effect visit to one link to another link within a scrolling box.
Syntax:
scroll-behavior:auto;
Example:
<!DOCTYPE html><html><head><title>CSS | scroll-behavior Property</title><style>.g4g {font-size:40px;font-weight:bold;color:green;text-align:center;}html {scroll-behavior: auto;}#geeks {height: 400px;background-color: coral;}#gfg {height: 400px;background-color: lightblue;}a {text-decoration:none;font-size:25px;font-weight:bold;}</style></head><body><divclass="g4g">GeeksforGeeks</div><h2style="text-align:center;">scroll-behaviour:auto;</h2><divclass="main"id="geeks"><ahref="#gfg">geeksforgeeks</p></div><divclass="main"id="gfg"><ahref="#geeks">GEEKSFORGEEKS</a><pstyle="color:green;">A computer science portal for geeks.</h3></div></body></html>chevron_rightfilter_noneOutput:

Supported Browsers: The browsers supported by scroll-behavior Property are listed below:
- Google Chrome 61.0
- Firefox 36.0
- Opera 48.0
Recommended Posts:
- CSS | transition-property Property
- CSS | nav-down property
- CSS | right Property
- CSS | nav-right property
- CSS | top Property
- CSS | all Property
- CSS | transition Property
- CSS | perspective Property
- CSS | left Property
- CSS overflow-y Property
- CSS | resize Property
- CSS | align-self Property
- CSS | flex Property
- CSS | clip Property
- CSS | Display property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



