overflow

Defines how a block level element should handle content that goes beyond its boundaries.

Syntax

overflow: <value>;

where <value> can be one of the following:

  • visible: the default value. No content will be clipped and a scrollbar will not appear.
  • hidden: content will be clipped and no scrollbar will appear.
  • scroll: content will be clipped and a scrollbar will appear.
  • auto: content will be clipped if it does not fit in the containing block, and a scrollbar will appear if it does.
  • Keyword values: initial, inherit, revert, unset.

Example 1

Clip any content that overflows without providing a scrollbar to view overflow content.

.view-box {
overflow: hidden;
}

Example 2

Provide a scrollbar and clip any content that overflows.

.view-box {
overflow: scroll;
}

Example 3

Provide a scrollbar only if overflow contents exists.

.view-box {
overflow: auto;
}

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn CSS on Codecademy

Contributors