The overflow-x and overflow-y properties are CSS level 3 extension of already defined property in CSS level 2.

Overflow-x

The overflow-x property specifies how to treat content's right and left edges in case of overflowing.

Syntax:

selector {

   overflow-x: visible | hidden | scroll | auto | initial | inherit;

}

Values:

The overflow-x property may take one of following three values:

  • visible; The content will not be clipped, but rather will be rendered outside the container. This is the default value.
  • hidden; The content will be clipped and left without any scroll bars.
  • scroll; The content will be clipped and scrolling will be provided always.
  • auto; Left for browser to decide, but in most cases in case the scrolling mechanism will appear in case of overflowing. Otherwise it will stay hidden.
  • initial, inherit

Overflow-y

The overflow-y property specifies how to treat content's top and bottom edges in case of overflowing.

Syntax:

selector {

   overflow-y: visible | hidden | scroll | auto | initial | inherit;

}

Values:

The overflow-x property may take one of following three values:

  • visibleThe content will not be clipped, but rather will be rendered outside the container. This is the default value.
  • hiddenThe content will be clipped and left without any scroll bars.
  • scrollThe content will be clipped and scrolling will be provided always.
  • autoLeft for browser to decide, but in most cases in case the scrolling mechanism will appear in case of overflowing. Otherwise it will stay hidden.
  • initial, inherit

Example

Overflow-x and overflow-y properties example:

 

›› go to examples ››