The overflow-y property controls what happens when content is taller than its container. It is essential for vertical scroll areas, fixed-height panels, chat lists, and modal bodies.
The overflow-y property in CSS controls what happens to the content when it overflows the vertical bounds of its container.
This property is particularly useful for managing vertical scrolling and ensuring that overflowing content is handled gracefully inside fixed-height layouts.
It applies only to the vertical axis, as opposed to the more general overflow property, which sets behavior for both axes at once.
Definition and Usage
Use overflow-y on elements with a defined height when content might exceed that height, such as chat message lists, modal bodies, sidebar panels, and scrollable article previews.
overflow-y: auto is the most common choice because a vertical scrollbar appears only when content actually overflows.
💡
Beginner Tip
Start with a 100px-tall container and several paragraphs plus overflow-y: auto;. Scroll vertically inside the box to see the effect.
Foundation
📝 Syntax
The syntax for the overflow-y property is as follows:
syntax.css
element{overflow-y:value;}
Here, value can be one of the predefined keywords described below.
Basic Example
overflow-y.css
.container{height:200px;overflow-y:auto;}
Syntax Rules
Accepted values: visible, hidden, scroll, and auto.
The container usually needs a set height or max-height for vertical overflow to matter.
overflow-y controls only the vertical axis; pair it with overflow-x for horizontal behavior.
auto is usually better than scroll when you want scrollbars only when needed.
Defaults
🎯 Default Value
The default value of the overflow-y property is visible. This means that if the content overflows vertically, it will not be clipped and will instead be visible beyond the bounds of its container.
Change it when you want to clip tall content or add vertical scrolling inside a fixed-height box.
Use overflow-y: scroll or auto when content may exceed a fixed container height.
Example 1 — Box with overflow-y: scroll
In this example, we’ll use the overflow-y property to add a vertical scrollbar to a 200px by 100px box containing lorem ipsum paragraphs.
overflow-y-scroll.html
<style>.overflow-box{width:200px;height:100px;border:1px solid #000;overflow-y:scroll;}</style><divclass="overflow-box"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent non nulla ut nunc fermentum dapibus.</p><p>Maecenas et ligula sit amet neque consequat aliquet. Nullam varius eros at eros efficitur.</p></div>
The message list should stay inside a fixed height.
overflow-y auto on the list container should work.
How It Works
The message list scrolls vertically while the chat header stays fixed above it.
Companion
overflow vs overflow-x vs overflow-y
The shorthand overflow sets both axes at once. Use overflow-x and overflow-y when horizontal and vertical behavior should differ.
overflow-companion.css
.modal-body{overflow-y:auto;overflow-x:hidden;}
A11y
♿ Accessibility
Do not hide important content — Using overflow-y: hidden can remove information from view with no way to scroll to it.
Ensure scrollable areas are usable — Keyboard users should be able to scroll focusable content inside vertical overflow containers.
Prefer auto over scroll — when you want vertical scrollbars only when content actually overflows.
Test small screens — Vertical overflow behavior affects modal dialogs, sidebars, and mobile panel layouts.
🧠 How overflow-y Works
1
Content exceeds container height
Long text, lists, images, or child elements may extend past the bottom edge.
Content
2
overflow-y value is applied
The browser decides whether to show, clip, or scroll extra height vertically.
Value
3
Layout stays controlled
Vertical scrollbars or clipping keep the page design tidy and predictable.
Result
=
↕
Managed vertical overflow
Users can scroll up and down or see clipped content based on your choice.
Compatibility
Browser Compatibility
The overflow-y property is well-supported across modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. It’s essential to test your designs in different browsers to ensure consistent behavior, especially when working with complex layouts or older browsers.
✓ Baseline · Universal support
Excellent support everywhere
visible, hidden, scroll, and auto work reliably in all major browsers.
99%Global browser support
Google Chrome1+ · All versions
Full support
Mozilla Firefox1+ · All versions
Full support
Apple Safari1+ · macOS & iOS
Full support
Microsoft Edge12+ · All versions
Full support
Opera4+ · All versions
Full support
overflow-y property99% supported
Bottom line:overflow-y is a dependable property for vertical overflow in modern projects.
Wrap Up
Conclusion
The overflow-y property is a valuable tool for controlling vertical overflow behavior in web design.
By properly using this property, you can ensure that your content is presented in a user-friendly way, whether it involves hiding overflow, providing scrollbars, or other behaviors. Experiment with different values to find the best solution for your design needs.
Use overflow-y: auto for chat lists, modals, and sidebar panels
Set height or max-height on overflow containers
Keep message lists inside a scrollable div
Pair with overflow-x when axes need different behavior
Test vertical overflow on mobile screen sizes
❌ Don’t
Hide important tall content with hidden without another way to access it
Use scroll everywhere when auto is enough
Expect overflow-y to work without height constraints on the box
Confuse overflow-y with overflow-wrap
Forget keyboard access inside vertically scrollable regions
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about overflow-y
Use these points when content exceeds its container height.
5
Core concepts
↕01
Vertical Overflow
Manage tall content.
Purpose
⚙02
Default visible
Show outside box.
Default
📝03
Four Values
visible to auto.
Values
🔄04
auto Scroll
Most common use.
Use case
↔05
overflow-x
Horizontal axis.
Companion
❓ Frequently Asked Questions
overflow-y controls what happens when content overflows the vertical bounds of its container, such as showing a vertical scrollbar or clipping extra height.
The default value is visible, which means overflowing content is shown outside the container along the vertical axis.
overflow is a shorthand that sets both horizontal and vertical overflow. overflow-y only affects the vertical axis.
Use auto when you want a vertical scrollbar only when content actually overflows. Use scroll when you always want vertical scrollbar tracks visible.
Both clip content, but clip also disables programmatic scrolling on the vertical axis. For most layouts, hidden is enough; clip is useful when you need stricter scroll containment.