Ask any question about CSS here... and get an instant response.
Post this Question & Answer:
How can I create a smooth scroll effect for anchor links using only CSS?
Asked on Mar 10, 2026
Answer
To create a smooth scroll effect for anchor links using only CSS, you can utilize the `scroll-behavior` property. This property allows you to control the scrolling behavior for the entire document or specific elements.
<!-- 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 page.
- This CSS property is supported in most modern browsers, but not all older versions.
- Ensure your anchor links are correctly set up with href attributes pointing to the corresponding IDs on the page.
Recommended Links:
