CSS overflow

The CSS overflow property allows you to determine what to when a box is too small for its contents. You can create scroll bars, hide the contents, or automatically expand the box.

As of CSS3, the overflow property is a shorthand property for the overflow-x and overflow-y properties (those properties were only introduced in CSS3). The overflow property allows you to set both of those properties at once.


Possible Values

The overflow property is shorthand, and accepts one or two keywords (below). If it has one keyword, that keyword sets both overflow-x and overflow-y; if it has two keywords, it sets overflow-x to the first and overflow-y to the second

Specifies that the content should not be clipped. In other words, it should be displayed outside the content box.
Specifies that the content is clipped (i.e. the parts that extend beyond the content box are hidden), and no scroll bars (or other scrolling mechanism) are supplied.
Specifies that the content box should provide scroll bars (or other scrolling mechanism) regardless of whether the content is clipped or not.
Specifies that the content box should provide scroll bars (or other scrolling mechanism) only when the content overflows (i.e. is too big to fit within the content box).

In addition, all CSS properties also accept the following CSS-wide keyword values as the sole component of their property value:

Represents the value specified as the property's initial value.
Represents the computed value of the property on the element's parent.
This value acts as either inherit or initial, depending on whether the property is inherited or not. In other words, it sets all properties to their parent value if they are inheritable or to their initial value if not inheritable.

General Information

Initial Value
See individual properties
Applies To

The exact wording depends on the spec:

  • CSS2: Block containers.
  • CSS basic box model: Non-replaced block-level elements and non-replaced 'inline-block' elements.
  • CSS Overflow Module Level 3: Block containers, flex containers, and grid containers.

Example Code

Official Specifications