CSS overflow Property

Description

The overflow CSS property controls what happens to content that is too big to fit into the specified area of an element. It can be used to hide the overflowing content, add scrollbars, or clip the overflowing content. The overflow property can be used on any element, but it is most commonly used on block elements with a specified height. Individual properties are: overflow-x and overflow-x.

Initial value
See individual properties
Applies to
Block containers
Inherited
No
Computed value
See individual properties
Animatable
No
JavaScript syntax
object.style.overflow

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: 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: visible;
}
.test2 {
   overflow: hidden; 
}
.test3 {
   overflow: scroll;
}
.test4 {
   overflow: auto; 
}

Browser Support

The following table will show you the current browser support for the CSS overflow property.

Desktop
Edge Chrome Firefox Opera Safari
121171
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
184141137

Last updated by CSSPortal on: 2nd January 2024