- Defaults to
visiblewhich allows content to spill outside its parent. overflowis shorthand foroverflow-xandoverflow-y.scrollwill hide the content and provide a scroll bar to make the content accessible.- The scroll bar will always be visible even if the content is small enough to fit in its parent.
- This can be useful to make dynamic content more smooth (adding / removing a scroll bar can be jarring).
autowill work likescrollbut will only add the scroll bar if needed.hiddenwill hide the content likescroll, but there won't be a way to access it (no scroll bar).- Useful for truncating text via ellipses.
- Useful for artistic designs.
visiblecan't be used with otheroverflowvalues. You can't hide content on one axis and show it on another axis (i.e. clip the content in one direction).- If an element is set to
overflow-x: hidden;andoverflow-y: visible;then theoverflow-ywill effectively be set toauto, so the content will be hidden and a scroll bar will be visible if needed. - As soon as
overflowis added, the element becomes a scroll container which prevents content from breaking out of its parent.
- If an element is set to
- To add horizontal scroll for inline elements:
white-space: nowrap;to removeinlinewrapping behavior.overflow: auto;to introduce thescrollbehavior.
position: absolute;elements will only respectoverflowwhich is set on its containing block.position: fixed;elements don't have an effect on overflow because the containing block is the viewport which doesn't have apositionvalue.