Ask any question about CSS here... and get an instant response.
Post this Question & Answer:
How can I create a smooth scrolling effect using only CSS?
Asked on Apr 17, 2026
Answer
To create a smooth scrolling effect using only CSS, you can utilize the `scroll-behavior` property. This property allows you to control the scrolling behavior of a webpage, making it smooth without the need for JavaScript.
<!-- BEGIN COPY / PASTE -->
<style>
html {
scroll-behavior: smooth;
}
</style>
<a href="#section2">Go to Section 2</a>
<div style="height: 1000px;"></div>
<h2 id="section2">Section 2</h2>
<!-- END COPY / PASTE -->Additional Comment:
- The `scroll-behavior: smooth;` property is applied to the `html` element to enable smooth scrolling for the entire page.
- This CSS property affects anchor links and any other scrollable elements on the page.
- Ensure that your links have the correct `href` attribute pointing to the corresponding `id` of the section you want to scroll to.
- Note that this property is supported in most modern browsers, but not in Internet Explorer.
Recommended Links:
