Favorites

CSS <overflow> Data Type

<overflow>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <overflow> data type is an overflow keyword: visible, hidden, clip, scroll or auto, which sets what happens to content that doesn't fit.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The <overflow> CSS data type represents the keywords that control what happens when an element's content is too big to fit inside its box. It is the value type of the overflow shorthand and its longhands overflow-x and overflow-y, as well as the logical properties overflow-block and overflow-inline.

The keywords fall into two groups. visible and clip do not create a scroll container: with visible, the default, overflowing content simply spills outside the box, and with clip it is cut off at the edge with no way to scroll to it. hidden, scroll and auto all turn the element into a scroll container. hidden cuts off the content but still allows it to be scrolled with code (for example with JavaScript or by focusing an element inside); scroll always shows scrollbars; and auto shows scrollbars only when they are needed.

The difference between hidden and clip is important in practice. Because hidden creates a scroll container, it affects position: sticky on descendants and creates a new block formatting context. clip avoids both, which makes it a good choice when you only want to trim content visually, and it can be combined with overflow-clip-margin to let content extend slightly past the edge. The overflow shorthand accepts one or two <overflow> values; with two, the first applies to the x axis and the second to the y axis.

Examples:

/* Scroll only when needed */
.chat-log {
  height: 300px;
  overflow: auto;
}

/* Hide horizontal overflow, allow vertical scrolling */
.code-panel {
  overflow: hidden auto;
}

/* Trim an image to rounded corners without a scroll container */
.avatar {
  border-radius: 50%;
  overflow: clip;
}

/* Always show scrollbars to avoid layout shift */
.sidebar {
  overflow-y: scroll;
}

Choosing the right <overflow> keyword keeps content accessible while preventing layouts from breaking when text, images or user content is larger than expected.

Interactive Demo

Typography is the art of arranging type. Good spacing, line length and alignment make text easy to read. Typography is the art of arranging type. Good spacing, line length and alignment make text easy to read.
Demo Code
HTML Code
<div class="demo-element">Typography is the art of arranging type. Good spacing, line length and alignment make text easy to read. Typography is the art of arranging type. Good spacing, line length and alignment make text easy to read.</div>
CSS Code
.demo-element {
	width: 220px;
	height: 90px;
	padding: 8px 10px;
	border: 2px solid #4361ee;
	background: #e7ecff;
	color: #1b1f3b;
	font-size: 14px;
	line-height: 1.5;
	overflow: visible;
}

Syntax

<overflow> = visible | hidden | clip | scroll | auto

Values

  • visibleContent is not clipped and may be drawn outside the element's padding box. This is the default value.
  • hiddenContent is clipped to the padding box and no scrollbars are shown, but the element is still a scroll container and can be scrolled programmatically.
  • clipContent is clipped at the overflow clip edge. The element is not a scroll container and cannot be scrolled, even programmatically.
  • scrollContent is clipped and scrollbars are always shown, whether or not the content overflows.
  • autoContent is clipped and scrollbars are shown only when the content overflows.

Example

<div class="wrap">
<h1>CSS &lt;overflow&gt; examples</h1>
<div class="grid">
<div>
<div class="label">visible</div>
<div class="box visible">This text is longer than the box can hold, so it overflows. Watch how each keyword handles the extra lines of content here.</div>
</div>
<div>
<div class="label">hidden</div>
<div class="box hidden">This text is longer than the box can hold, so it overflows. Watch how each keyword handles the extra lines of content here.</div>
</div>
<div>
<div class="label">clip</div>
<div class="box clip">This text is longer than the box can hold, so it overflows. Watch how each keyword handles the extra lines of content here.</div>
</div>
<div>
<div class="label">scroll</div>
<div class="box scroll">This text is longer than the box can hold, so it overflows. Watch how each keyword handles the extra lines of content here.</div>
</div>
<div>
<div class="label">auto</div>
<div class="box auto">This text is longer than the box can hold, so it overflows. Watch how each keyword handles the extra lines of content here.</div>
</div>
</div>
</div>
/* Compares each  keyword */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f4f6f8;
  color: #0f172a;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  margin: 0 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 28px 18px;
}

.label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.box {
  height: 120px;
  padding: 10px;
  background: #fff;
  border: 2px solid #2563eb;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.visible { overflow: visible; }
.hidden { overflow: hidden; }
.clip { overflow: clip; }
.scroll { overflow: scroll; }
.auto { overflow: auto; }
Open in editor

Browser Support

The following information will show you the current browser support for the CSS overflow data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.