overflow-x
Quick Summary for overflow-x
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.
Code Usage for overflow-x
/* 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: unset; 
More Details for overflow-x

overflow-x

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.

Syntax

/* 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: unset; 

The overflow-x property is specified as a single keyword chosen from the list of values below.

Values

visible

Content is not clipped and may be rendered outside the padding box's left and right edges. If overflow-y is hidden, scroll or auto and this property is visible, it will implicitly compute to auto.

hidden

Content is clipped if necessary to fit horizontally in the padding box. No scrollbars are provided.

clip

Like for hidden, the content is clipped to the element's padding box. The difference between clip and hidden is that the clip keyword also forbids all scrolling, including programmatic scrolling. The box is not a scroll container, and does not start a new formatting context. If you wish to start a new formatting context, you can use display: flow-root to do so.

scroll

Content is clipped if necessary to fit horizontally in the padding box. Browsers display scrollbars whether or not any content is actually clipped. (This prevents scrollbars from appearing or disappearing when the content changes.) Printers may still print overflowing content.

auto

Depends on the user agent. If content fits inside the padding box, it looks the same as visible, but still establishes a new block-formatting context. Desktop browsers provide scrollbars if content overflows.

Formal definition

Initial valuevisible
Applies toBlock-containers, flex containers, and grid containers
Inheritedno
Computed valueas specified, except with visible/clip computing to auto/hidden respectively if one of overflow-x or overflow-y is neither visible nor clip
Animation typediscrete

Formal syntax

visible | hidden | clip | scroll | auto

Examples

HTML

<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> 

CSS

#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;} 

Result

Specifications

Specification
CSS Overflow Module Level 3 # overflow-properties

See also

Related CSS properties: text-overflow, white-space, overflow, overflow-y, clip, display

Last modified: Aug 12, 2021, by MDN contributors

Select your preferred language English (US)Français日本語中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
time you enjoyed wasting is not wasted time
Unknown
Random CSS Property

font-family

The font-family CSS property specifies a prioritized list of one or more font family names and/or generic family names for the selected element.
font-family css reference