files/en-us/web/css/reference/properties/overflow-x/index.md
The overflow-x CSS property sets what shows when content overflows a block-level element's left and right edges. This may be nothing, a scroll bar, or the overflow content. This property may also be set by using the {{cssxref("overflow")}} shorthand property.
{{InteractiveExample("CSS Demo: overflow-x")}}
overflow-x: visible;
overflow-x: hidden;
overflow-x: clip;
overflow-x: scroll;
overflow-x: auto;
<section class="default-example" id="default-example">
<div id="example-element">
The value of Pi is 3.1415926535897932384626433832795029. The value of e is
2.7182818284590452353602874713526625.
</div>
</section>
#example-element {
width: 15em;
height: 9em;
border: medium dotted;
padding: 0.75em;
text-align: left;
}
/* Keyword values */
overflow-x: visible;
overflow-x: hidden;
overflow-x: clip;
overflow-x: scroll;
overflow-x: auto;
/* Global values */
overflow-x: inherit;
overflow-x: initial;
overflow-x: revert;
overflow-x: revert-layer;
overflow-x: unset;
The overflow-x property is specified as a single {{CSSXref("overflow_value", "<overflow>")}} keyword value.
If {{cssxref("overflow-y")}} is hidden, scroll, or auto, and the overflow-x property is visible (default), the value will be implicitly computed as auto.
visible
hidden
clip
overflow-clip-margin or by 0px if not set. The difference between clip and hidden is that the clip keyword also forbids all scrolling, including programmatic scrolling. No new formatting context is created. To establish a formatting context, use overflow: clip along with {{cssxref("display", "display: flow-root", "#flow-root")}}. The element box is not a scroll container.scroll
auto
scroll, user agents display scroll bars only if the content is overflowing and hide scroll bars by default. If content fits inside the element's padding box, it looks the same as with visible, but still establishes a new block-formatting context. Desktop browsers provide scroll bars if content overflows.[!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.
{{CSSInfo}}
{{csssyntax}}
<ul>
<li>
<code>overflow-x:hidden</code> — hides the text outside the box
<div id="div1">ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ</div>
</li>
<li>
<code>overflow-x:scroll</code> — always adds a scrollbar
<div id="div2">ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ</div>
</li>
<li>
<code>overflow-x:visible</code> — displays the text outside the box if
needed
<div id="div3">ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ</div>
</li>
<li>
<code>overflow-x:auto</code> — on most browsers, equivalent to
<code>scroll</code>
<div id="div4">ABCDEFGHIJKLMOPQRSTUVWXYZABCDEFGHIJKLMOPQRSTUVWXYZ</div>
</li>
</ul>
#div1,
#div2,
#div3,
#div4 {
border: 1px solid black;
width: 250px;
margin-bottom: 12px;
}
#div1 {
overflow-x: hidden;
}
#div2 {
overflow-x: scroll;
}
#div3 {
overflow-x: visible;
}
#div4 {
overflow-x: auto;
}
{{EmbedLiveSample("Examples", "100%", "270")}}
{{Specifications}}
{{Compat}}