<overflow> CSS type

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

The <overflow> enumerated value type represents the keyword values for the overflow-block, overflow-inline, overflow-x, and overflow-y longhand properties and the overflow shorthand property. These properties apply to block containers, flex containers, and grid containers.

Syntax

<overflow> = visible | hidden | clip | scroll | auto

Values

The <overflow> enumerated value type is specified using one of the values listed below.

visible

Overflow content is not clipped and may be visible outside the element's padding box. The element box is not a scroll container. This is the default value for all the properties that have the <overflow> enumerated value type.

hidden

Overflow content is clipped at the element's padding box. There are no scroll bars, and the clipped content is not visible (i.e., clipped content is hidden), but the content still exists. User agents do not add scrollbars and also do not allow users to view the content outside the clipped region by actions such as dragging on a touch screen or using the scroll wheel on a mouse. The content can be scrolled programmatically (for example, by setting the value of the scrollLeft property or the scrollTo() method). The content can also be scrolled via keyboard interaction; arrows enable scrolling through the content and tabbing to a focusable element within the hidden content enables scrolling the focused element into view. The element box on which this value is set is a scroll container.

clip

Overflow content is clipped at the element's overflow clip edge that is defined using the overflow-clip-margin property. As a result, content overflows the element's padding box by the <length> value of 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

Overflow content is clipped at the element's padding box, and overflow content can be scrolled into view using scrollbars. User agents display scrollbars in both horizontal and vertical directions if only one value is set, whether or not any content is overflowing or clipped. The use of this keyword value, therefore, can prevent scrollbars from appearing and disappearing as content changes. Printers may still print overflowing content. The element box on which this value is set is a scroll container.

auto

Overflow content is clipped at the element's padding box, and overflow content can be scrolled into view. Unlike 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 overlay is a legacy value alias for auto. With overlay, the scroll bars are drawn on top of the content instead of taking up space.

Examples

This example demos all the <overflow> enumerated values for the overflow property.

HTML

The HTML in this example contains some lyrics within the <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.

html
<pre>&nbsp;
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>

CSS

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 overflow-clip-margin has been added.

css
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: ";
}

Result

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

Specification
CSS Overflow Module Level 3
# propdef-overflow

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
overflow
Chrome – Full support
Chrome 1 (Release date: 2008-12-11)
footnote Full support
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Full support
Firefox 1 (Release date: 2004-11-09)
footnote Full support
Opera – Full support
Opera 7 (Release date: 2003-01-28)
footnote Full support
Safari – Full support
Safari 1 (Release date: 2003-06-23)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 4 (Release date: 2011-03-29)
footnote Full support
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 1 (Release date: 2007-06-29)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote Full support
WebView Android – Full support
WebView Android 37 (Release date: 2014-09-03)
footnote Full support
WebView on iOS – Full support
WebView on iOS 1 (Release date: 2007-06-29)
footnote Full support
clip
Chrome – Full support
Chrome 90 (Release date: 2021-04-13)
footnote Full support
Edge – Full support
Edge 90 (Release date: 2021-04-15)
footnote Full support
Firefox – No support
Firefox 1.5 – 80 (Release date: 2005-11-29)
altname
altname Alternate name: -moz-hidden-unscrollable
Firefox – Full support
Firefox 81 (Release date: 2020-09-22)
footnote Full support
Opera – Full support
Opera 76 (Release date: 2021-04-28)
footnote Full support
Safari – Full support
Safari 16 (Release date: 2022-09-12)
footnote Full support
Chrome Android – Full support
Chrome Android 90 (Release date: 2021-04-13)
footnote Full support
Firefox for Android – No support
Firefox for Android 4 – 80 (Release date: 2011-03-29)
altname
altname Alternate name: -moz-hidden-unscrollable
Firefox for Android – Full support
Firefox for Android 81 (Release date: 2020-09-22)
footnote Full support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Full support
Safari on iOS 16 (Release date: 2022-09-12)
footnote Full support
Samsung Internet – Full support
Samsung Internet 15 (Release date: 2021-08-13)
footnote Full support
WebView Android – Full support
WebView Android 90 (Release date: 2021-04-13)
footnote Full support
WebView on iOS – Full support
WebView on iOS 16 (Release date: 2022-09-12)
footnote Full support
overlay
Deprecated
Chrome – Partial support
Chrome 15 – 113 (Release date: 2011-10-25)
footnote Partial support
footnote Before version 114, the overlay keyword caused non-standard behavior, allowing scrollbars to overlay content without taking up layout space. From version 114, the keyword aliases to the standard auto keyword. See bug 40444262.
Chrome – Full support
Chrome 114 (Release date: 2023-05-30)
footnote Full support
Edge – Partial support
Edge 79 – 113 (Release date: 2020-01-15)
footnote Partial support
footnote Before version 114, the overlay keyword caused non-standard behavior, allowing scrollbars to overlay content without taking up layout space. From version 114, the keyword aliases to the standard auto keyword. See bug 40444262.
Edge – Full support
Edge 114 (Release date: 2023-06-02)
footnote Full support
Firefox – Full support
Firefox 112 (Release date: 2023-04-11)
footnote Full support
Opera – Partial support
Opera 15 – 99 (Release date: 2013-07-02)
footnote Partial support
footnote Before version 100, the overlay keyword caused non-standard behavior, allowing scrollbars to overlay content without taking up layout space. From version 100, the keyword aliases to the standard auto keyword. See bug 40444262.
Opera – Full support
Opera 100 (Release date: 2023-06-29)
footnote Full support
Safari – Partial support
Safari 4 – 11.1 (Release date: 2009-06-08)
footnote Partial support
footnote Before version 12, the overlay keyword caused non-standard behavior, allowing scrollbars to overlay content without taking up layout space. From version 12, the keyword aliases to the standard auto keyword. See bug 189811.
Safari – Full support
Safari 12 (Release date: 2018-09-17)
footnote Full support
Chrome Android – Partial support
Chrome Android 100 – 113 (Release date: 2022-03-29)
footnote Partial support
footnote Before version 114, the overlay keyword caused non-standard behavior, allowing scrollbars to overlay content without taking up layout space. From version 114, the keyword aliases to the standard auto keyword. See bug 40444262.
Chrome Android – Full support
Chrome Android 114 (Release date: 2023-05-30)
footnote Full support
Firefox for Android – Full support
Firefox for Android 112 (Release date: 2023-04-11)
footnote Full support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – Partial support
Safari on iOS 3.2 – 11.3 (Release date: 2010-04-03)
footnote Partial support
footnote Before version 12, the overlay keyword caused non-standard behavior, allowing scrollbars to overlay content without taking up layout space. From version 12, the keyword aliases to the standard auto keyword. See bug 189811.
Safari on iOS – Full support
Safari on iOS 12 (Release date: 2018-09-17)
footnote Full support
Samsung Internet – Full support
Samsung Internet 4 (Release date: 2016-03-11)
footnote Full support
WebView Android – Partial support
WebView Android 100 – 113 (Release date: 2022-03-29)
footnote Partial support
footnote Before version 114, the overlay keyword caused non-standard behavior, allowing scrollbars to overlay content without taking up layout space. From version 114, the keyword aliases to the standard auto keyword. See bug 40444262.
WebView Android – Full support
WebView Android 114 (Release date: 2023-05-30)
footnote Full support
WebView on iOS – Partial support
WebView on iOS 3.2 – 11.3 (Release date: 2010-04-03)
footnote Partial support
footnote Before version 12, the overlay keyword caused non-standard behavior, allowing scrollbars to overlay content without taking up layout space. From version 12, the keyword aliases to the standard auto keyword. See bug 189811.
WebView on iOS – Full support
WebView on iOS 12 (Release date: 2018-09-17)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Deprecated. Not for use in new websites.
Uses a non-standard name
Has more compatibility info.

See also