Overflow

The overflow CSS property controls how content that exceeds the bounds of an element is handled. It is defined by two axes representing the horizontal (x-axis) and vertical (y-axis) overflow behaviors. Here is a breakdown of its axes:


Horizontal (x-axis Overflow ):

  • Can take values like visible, hidden, scroll, or auto.

  • Determines how content that overflows horizontally (left or right) is displayed.

  • Commonly used to allow or prevent horizontal scrolling.

  • scroll and auto can add horizontal scrollbars if needed.


Vertical (y-axis Overflow):

  • Can take values like visible, hidden, scroll, or auto.

  • Determines how content that overflows vertically (top or bottom) is displayed.

  • Useful for scrollable content areas such as modals or dropdowns.

  • scroll and auto can add vertical scrollbars when content exceeds height.


The overflow property allows precise control over how overflowing content is managed inside a container, improving layout control and user experience.

Possible Values

Values
Units
Description

visible

N/A

Content is not clipped and appears outside the container if it overflows.

hidden

N/A

Content is clipped to fit the container dimensions and no scrollbars are added.

scroll

N/A

Scrollbars are added to view the content that exceeds the container boundaries.

auto

N/A

Browser decides whether to clip content or provide scrollbars as needed.

inherit

N/A

Inherits the overflow value from its parent element.

overlay

N/A

It allows content to overflow (i.e., scroll) but displays scrollbars on top of the content

initial

N/A

It resets the overflow property to its default (initial) value

unset

N/A

It resets the overflow property to its inherited value if possible, otherwise to its default (visible).

Example

  1. To manage overflowing content in a container, you can set Horizontal (overflow-x ) to Hidden and Vertical (overflow-y ) to Scroll to hide horizontal overflow and enable scrolling for vertical overflow.

  1. In this example, the outer container has a width of 100%, while the inner content's container has a width of 150%. To manage the horizontal overflow and allow scrolling when needed, you can set Horizontal (overflow-x ) to Auto

Conditional Values

what are conditional values?

These properties can also be configured using conditional values by expanding the formula editor.

For Example

  • You can conditionally enable or disable scrolling based on screen size, hiding it on mobile devices and allowing it on larger screens if content overflows.

Setting horizontal overflow based on current device

Last updated