CSS Portal

CSS overflow-y Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The overflow-y property controls how content that overflows a box along the vertical axis is handled by the formatting/painting system. It determines whether the box clips the overflowed content, creates a vertical scrolling mechanism, or delegates the overflow behavior to other layout rules. Because it applies specifically to the vertical direction, it is often used when you want independent control of vertical behavior while leaving horizontal handling to another property such as overflow-x or the shorthand overflow.

In terms of layout, setting overflow-y can cause an element to become a scroll container for its descendants; that affects how descendants participate in scrolling and which ancestor serves as their scroll-snap or containing block for various layout effects. Its interaction with fixed-size constraints is common: a scroll container usually appears when an element has a constrained size (for example via height or width), and the overflow behavior will determine whether excess content is clipped or made scrollable. Because the element becomes the source of vertical scroll, user input (keyboard, wheel, touch) and focus navigation will target that container rather than an outer one.

Practical considerations include nested scroll chains and how multiple scrollable ancestors interact on touch devices or when programmatically scrolling; thoughtful use of overflow-y helps avoid surprising nested scroll behavior. It also interacts with how elements are rendered and composited: creating scrollable regions can change painting boundaries and hardware-accelerated layers, which has implications for performance in complex UIs. Finally, when using overflow-y, remember how it pairs with layout contexts set by other properties - display modes (for example controlled by display) and positioning rules (see position) can affect both the appearance and the scrolling behavior of the element - so consider those interactions when designing scrollable components.

Definition

Initial value
visible
Applies to
Block containers, flex containers and grid containers
Inherited
No
Computed value
As specified
Animatable
No
JavaScript syntax
object.style.overflowY

Interactive Demo

The rusty swing set creaked a lonely lullaby in the twilight, shadows lengthening like grasping fingers across the dew-kissed grass. A lone dandelion seed, adrift on the breeze, whispered secrets of faraway fields, of dandelion suns and galaxies spun from fluff. Somewhere, beyond the veil of dusk, a coyote laughed, echoing through the stillness like a forgotten memory.

Syntax

overflow-y: visible | hidden | scroll | auto

Values

  • visibleContent is not clipped and scroll bars are not added. Elements are clipped to the size of the containing window or frame.
  • hiddenContent that exceeds the dimensions of the object is not shown.
  • scrollContent is clipped and scroll bars are added, even if the content does not exceed the dimensions of the object.
  • autoContent is clipped and scrolling is added only when necessary.

Example

<div class="test"> visible
<img src="images/tech.gif" alt="">
</div>
<div class="test2"> hidden
<img src="images/tech.gif" alt="">
</div>
<div class="test3"> scroll
<img src="images/tech.gif" alt="">
</div>
<div class="test4"> auto
<img src="images/tech.gif" alt="">
</div>
div {
   display: inline-block; 
   margin-right: 30px;
   width: 100px; 
   height: 100px;
   border: 2px solid blue; 
}
img {
   width: 125px;
   height: 125px;
}
.test {
   overflow-x: visible;
   overflow-y: visible;
}
.test2 {
   overflow-x: hidden;
   overflow-y: hidden; 
}
.test3 {
   overflow-x: scroll;
   overflow-y: scroll;
}
.test4 {
   overflow-x: auto;
   overflow-y: auto; 
}

Browser Support

The following information will show you the current browser support for the CSS overflow-y property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!