
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS scroll-behavior Property
The scroll-behavior property is used to set the behaviour of scroll. We can set the following different property values for the scroll-behavior property −
scroll-behavior: auto|smooth|initial|inherit;
Example
Let us now see an example to implement the sroll-behavior property −
<!DOCTYPE html> <html> <head> <style> html { scroll-behavior: smooth; } #area1 { height: 400px; background-color: red; } #area2 { height: 600px; background-color: orange; } #area3 { height: 550px; background-color: magenta; } </style> </head> <body> <h1>Demo Heading</h1> <div class="main" id="area1"> <h2>Section 1</h2> <a href="#area2">Reach Section 2</a> </div> <div class="main" id="area2"> <h2>Section 2</h2> <a href="#area3">Reach Section 3</a> </div> <div class="main" id="area3"> <h2>Section 3</h2> <a href="#area1">Reach Section 1</a> </div> </body> </html>
Output
Now, click “Reach Section 2” −
Now, click “Reach Section 3” for smooth scroll to Section 3 −
- Related Articles
- Modify the behavior of the flex-wrap property with CSS
- CSS overflow: scroll
- Disabling Scroll Anchoring with CSS
- How to change background images on scroll with CSS?
- HTML Tables with Fixed Header on Scroll in CSS
- How to create a scroll indicator with CSS and JavaScript?
- How to create a "scroll back to top" button with CSS?
- How to create a gradient background color on scroll with CSS?
- How to shrink a header on scroll with CSS and JavaScript?
- How to Create an On Scroll Fixed Navigation Bar with CSS?
- CSS padding property
- CSS outline property
- CSS Transition property
- CSS flex property
- CSS order property

Advertisements