Scrolling is one of the fundamental interaction elements of websites. CSS offers several options to define how content appears when it exceeds the display or a box size. In addition, modern browsers support smooth scrolling, which provides a better user experience.
With the overflow property, we can control what happens when the content exceeds the size of its parent element. The values include visible (default), hidden, scroll, and auto. The scroll value ensures that the scrollbar is always visible, while auto only shows it when necessary.
In this example, we create a fixed-size box that contains enough text to require scrolling. With overflow: scroll, the scrollbar will always be visible.
The scroll-behavior property allows us to set scrolling to happen smoothly when the user clicks on a link that points within the same page. This provides a much more pleasant user experience, especially on longer pages.
In this example, we place a link that points to a later part of the page. With scroll-behavior: smooth, the browser scrolls to the target element slowly with continuous motion.
Customizing scrolling can help create a better user experience, but accessibility and performance should always be kept in mind.
Please sign in to ask Lara about CSS scroll.
Select Language
Set theme
© 2025 ReadyTools. All rights reserved.