Ask any question about CSS here... and get an instant response.
Post this Question & Answer:
How can I create a smooth scrolling effect for anchor links in CSS?
Asked on Mar 29, 2026
Answer
To create a smooth scrolling effect for anchor links using CSS, you can utilize the `scroll-behavior` property. This property allows you to define how scrolling should behave, and setting it to "smooth" will enable a smooth transition when navigating to anchor links.
<!-- BEGIN COPY / PASTE -->
html {
scroll-behavior: smooth;
}
<!-- END COPY / PASTE -->Additional Comment:
- The `scroll-behavior: smooth;` property should be applied to the `html` element to affect the entire document.
- This CSS property is supported in most modern browsers, but not all (e.g., Internet Explorer).
- For browsers that do not support this property, JavaScript can be used as a fallback for smooth scrolling.
- Ensure that your anchor links are correctly set up with href attributes pointing to the target IDs.
Recommended Links:
