Ask any question about CSS here... and get an instant response.
Post this Question & Answer:
How can I use CSS to create a smooth scrolling effect for anchor links on my webpage?
Asked on Mar 01, 2026
Answer
To create a smooth scrolling effect for anchor links on your webpage using CSS, you can utilize the `scroll-behavior` property. This property allows you to control the scrolling behavior of the document when navigating to an anchor link.
<!-- BEGIN COPY / PASTE -->
html {
scroll-behavior: smooth;
}
<!-- END COPY / PASTE -->Additional Comment:
- The `scroll-behavior: smooth;` property is applied to the `html` element to enable smooth scrolling for the entire document.
- This property is supported in most modern browsers, but you should check compatibility if targeting older versions.
- No JavaScript is needed for this effect, making it a simple and efficient solution.
- Ensure your anchor links are correctly set up with href attributes pointing to the target element's id.
Recommended Links:
