files/en-us/web/css/reference/values/overflow_value/index.md
The <overflow> {{glossary("enumerated")}} value type represents the keyword values for the {{cssxref("overflow-block")}}, {{cssxref("overflow-inline")}}, {{cssxref("overflow-x")}}, and {{cssxref("overflow-y")}} longhand properties and the {{cssxref("overflow")}} shorthand property. These properties apply to block containers, flex containers, and grid containers.
<overflow> = visible | hidden | clip | scroll | auto
The <overflow> enumerated value type is specified using one of the values listed below.
visible
<overflow> enumerated value type.hidden
clip
overflow-clip-margin or by 0px if not set. Overflow content outside the clipped region is not visible, user agents do not add a scrollbar, and programmatic scrolling is also not supported. No new formatting context is created.scroll
auto
scroll, user agents display scrollbars only if the content is overflowing and hide scrollbars by default. If content fits inside the element's padding box, it looks the same as with visible but still establishes a new formatting context. The element box on which this value is set is a scroll container.[!NOTE] The keyword value
overlayis a legacy value alias forauto. Withoverlay, the scroll bars are drawn on top of the content instead of taking up space.
This example demos all the <overflow> enumerated values for the {{cssxref("overflow")}} property.
The HTML in this example contains some lyrics within the {{HTMLELement("pre")}} element. The HTML also contains a link text to enable testing the effects of keyboard focus on overflow and scroll behaviors. The same HTML code is repeated multiple times to show the effect of each <overflow> enumerated value.
<pre>
Oh, Rubber Duckie, you're the one
You make bath time lots of fun
Rubber Duckie, I'm awfully fond of you
Rubber Duckie, joy of joys
When I squeeze you, you make noise
Rubber Duckie, you're my very best friend, it's true
Oh, every day when I make my way to the tubby
I find a little fella who's cute and yellow and chubby
Rub-a-dub-dubby
<a href="#">Rubber Duckie</a>, you're so fine
And I'm lucky that you're mine
Rubber Duckie, I'm awfully fond of you
</pre>
<pre>
Oh, Rubber Duckie, you're the one
You make bath time lots of fun
Rubber Duckie, I'm awfully fond of you
Rubber Duckie, joy of joys
When I squeeze you, you make noise
Rubber Duckie, you're my very best friend, it's true
Oh, every day when I make my way to the tubby
I find a little fella who's cute and yellow and chubby
Rub-a-dub-dubby
<a href="#">Rubber Duckie</a>, you're so fine
And I'm lucky that you're mine
Rubber Duckie, I'm awfully fond of you
</pre>
<pre>
Oh, Rubber Duckie, you're the one
You make bath time lots of fun
Rubber Duckie, I'm awfully fond of you
Rubber Duckie, joy of joys
When I squeeze you, you make noise
Rubber Duckie, you're my very best friend, it's true
Oh, every day when I make my way to the tubby
I find a little fella who's cute and yellow and chubby
Rub-a-dub-dubby
<a href="#">Rubber Duckie</a>, you're so fine
And I'm lucky that you're mine
Rubber Duckie, I'm awfully fond of you
</pre>
<pre>
Oh, Rubber Duckie, you're the one
You make bath time lots of fun
Rubber Duckie, I'm awfully fond of you
Rubber Duckie, joy of joys
When I squeeze you, you make noise
Rubber Duckie, you're my very best friend, it's true
Oh, every day when I make my way to the tubby
I find a little fella who's cute and yellow and chubby
Rub-a-dub-dubby
<a href="#">Rubber Duckie</a>, you're so fine
And I'm lucky that you're mine
Rubber Duckie, I'm awfully fond of you
</pre>
<pre>
Oh, Rubber Duckie, you're the one
You make bath time lots of fun
Rubber Duckie, I'm awfully fond of you
Rubber Duckie, joy of joys
When I squeeze you, you make noise
Rubber Duckie, you're my very best friend, it's true
Oh, every day when I make my way to the tubby
I find a little fella who's cute and yellow and chubby
Rub-a-dub-dubby
<a href="#">Rubber Duckie</a>, you're so fine
And I'm lucky that you're mine
Rubber Duckie, I'm awfully fond of you
</pre>
<pre>
Oh, Rubber Duckie, you're the one
You make bath time lots of fun
Rubber Duckie, I'm awfully fond of you
Rubber Duckie, joy of joys
When I squeeze you, you make noise
Rubber Duckie, you're my very best friend, it's true
Oh, every day when I make my way to the tubby
I find a little fella who's cute and yellow and chubby
Rub-a-dub-dubby
<a href="#">Rubber Duckie</a>, you're so fine
And I'm lucky that you're mine
Rubber Duckie, I'm awfully fond of you
</pre>
For the purpose of demonstration, the size of the <pre> element box has been defined to ensure that the content overflows its container in both the inline and block directions. A different <overflow> value is set for each of the repeating <pre> elements. For the clip value demonstration, an {{CSSXref("overflow-clip-margin")}} has been added.
pre {
border: 2px dashed red;
margin-bottom: 3em;
}
::before {
font-weight: bold;
color: white;
background: crimson;
display: inline-block;
width: 100%;
padding: 3px 5px;
box-sizing: border-box;
}
pre {
block-size: 100px;
inline-size: 295px;
}
pre:nth-of-type(1) {
overflow: hidden;
}
pre:nth-of-type(1)::before {
content: "hidden: ";
}
pre:nth-of-type(2) {
overflow: clip;
overflow-clip-margin: 1em;
}
pre:nth-of-type(2)::before {
content: "clip: ";
}
pre:nth-of-type(3) {
overflow: scroll;
}
pre:nth-of-type(3)::before {
content: "scroll: ";
}
pre:nth-of-type(4) {
overflow: auto;
}
pre:nth-of-type(4)::before {
content: "auto: ";
}
pre:nth-of-type(5) {
overflow: clip;
overflow: overlay;
overflow-clip-margin: 3em;
}
pre:nth-of-type(5)::before {
content: "overlay (or clip if not supported): ";
}
pre:nth-of-type(6) {
overflow: visible;
}
pre:nth-of-type(6)::before {
content: "visible: ";
}
{{EmbedLiveSample("Examples", "500", "800")}}
To see the effect of keyboard focus on overflow and scroll behaviors, try tabbing through all the links in the example. Notice that the clip box does not create a scroll container, and the link does not come into view when the link is focused. The visible value, which has the link always in view, is also not a scroll container.
{{Specifications}}
{{Compat}}