CSS overflow Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout & Scrolling

What You’ll Learn

The overflow property decides what happens when content is bigger than its container. It is essential for scroll areas, clipped layouts, and clean UI design.

01

Overflow Control

Manage extra content.

02

Four Values

visible to auto.

03

Default visible

Show outside box.

04

Scrollbars

scroll vs auto.

05

Clip Content

Use hidden.

06

overflow-x/y

Axis control.

Introduction

The overflow property in CSS controls how content that overflows the bounds of its container is handled.

This property is crucial for managing content that exceeds the dimensions of its container, allowing you to specify how to handle overflowed content in a way that fits your design needs.

Definition and Usage

Use overflow on elements with a defined width or height when content might exceed those limits, such as cards, sidebars, code blocks, and modal bodies.

auto is the most common choice for scrollable panels because scrollbars appear only when needed.

💡
Beginner Tip

Start with a fixed-size box and overflow: auto;. If content is too long, scrollbars appear automatically.

📝 Syntax

The syntax for the overflow property is as follows:

syntax.css
element {
  overflow: value;
}

Here, value can be one of the defined keywords or a combination of values for each axis.

Basic Example

overflow.css
.container {
  width: 200px;
  height: 100px;
  overflow: auto;
}

Syntax Rules

  • Common values: visible, hidden, scroll, and auto.
  • The container usually needs a set width, height, or max-size for overflow to matter.
  • overflow-x and overflow-y control horizontal and vertical overflow separately.
  • auto is usually better than scroll when you want scrollbars only when needed.

🎯 Default Value

The default value of the overflow property is visible, meaning that content overflowing the bounds of the container will be rendered outside the container.

Change it when you want to clip content or add scrolling inside a fixed-size box.

⚡ Quick Reference

QuestionAnswer
Initial valuevisible
Applies toBlock containers and flex/grid items
InheritedNo
AnimatableNo
Common useScrollable panels, clipped content, layout control

💎 Property Values

ValueExampleDescription
visibleoverflow: visible;Overflowed content is visible outside the container (default)
hiddenoverflow: hidden;Overflowed content is clipped and no scrollbars are shown
scrolloverflow: scroll;Scrollbars are always added to the container
autooverflow: auto;Scrollbars appear only when content overflows
visible — default hidden — clip content scroll — always scroll auto — scroll when needed

👀 Live Preview

Same long text in small boxes with different overflow values (scroll inside the boxes):

auto
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum.
hidden
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum.
scroll
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum.

Examples Gallery

Manage overflowing text with auto scrollbars, hidden clipping, and value comparisons.

🗃 Scrollable Containers

Use overflow: auto when content may exceed a fixed box size.

Example 1 — Container with overflow: auto

In this example, we use the overflow property to manage overflowed content within a div element.

overflow-auto.html
<style>
  .container {
    width: 200px;
    height: 100px;
    border: 1px solid #000;
    overflow: auto;
  }
</style>

<div class="container">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
</div>
Try It Yourself

How It Works

Scrollbars appear only when the paragraph exceeds the container’s 200×100 pixel size.

Example 2 — Clip Content with hidden

Hide overflowed content without showing scrollbars.

overflow-hidden.css
.card {
  width: 240px;
  height: 80px;
  overflow: hidden;
  border-radius: 0.5rem;
}
Try It Yourself

How It Works

Content beyond the box edge is cut off and cannot be scrolled into view.

🔄 Scroll & Compare

Compare always-on scrollbars and visible overflow behavior.

Example 3 — Always Show Scrollbars with scroll

Use scroll when you want scrollbars present even if content fits.

overflow-scroll.css
.panel {
  width: 220px;
  height: 120px;
  overflow: scroll;
}
Try It Yourself

How It Works

Unlike auto, scroll reserves scrollbar space even when content does not overflow.

Example 4 — visible vs hidden

See the difference between default visible overflow and clipped hidden overflow.

visible-vs-hidden.css
.visible-box { overflow: visible; }
.hidden-box { overflow: hidden; }
Try It Yourself

How It Works

visible lets content extend beyond the box; hidden keeps it inside visually.

overflow-x and overflow-y

The shorthand overflow sets both axes. Use overflow-x and overflow-y when you want horizontal and vertical behavior to differ.

overflow-axes.css
.code-block {
  overflow-x: auto;
  overflow-y: hidden;
}

♿ Accessibility

  • Do not hide important content — Using hidden can remove information from view with no way to scroll to it.
  • Ensure scrollable areas are usable — Keyboard users should be able to scroll focusable content inside overflow containers.
  • Prefer auto over scroll — when you want scrollbars only when content actually overflows.
  • Test small screens — Overflow behavior affects mobile layouts and readability.

🧠 How overflow Works

1

Content fills a container

Text, images, or child elements may exceed the box size.

Content
2

overflow value is applied

The browser decides whether to show, clip, or scroll extra content.

Value
3

Layout stays controlled

Scrollbars or clipping keep the page design tidy and predictable.

Result
=

Managed overflow behavior

Users can view, scroll, or ignore extra content based on your choice.

Browser Compatibility

The overflow property is well supported across all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. This makes it a reliable option for managing content overflow in various web environments.

Baseline · Universal support

Excellent support everywhere

visible, hidden, scroll, and auto work reliably in all major browsers.

99% Global browser support
Google Chrome 1+ · All versions
Full support
Mozilla Firefox 1+ · All versions
Full support
Apple Safari 1+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 4+ · All versions
Full support
overflow property 99% supported

Bottom line: overflow is one of the most dependable layout properties in CSS.

Conclusion

The overflow property is an essential tool for managing how content that exceeds the bounds of its container is handled.

By choosing the appropriate value—whether it’s visible, hidden, scroll, or auto—you can control how users interact with overflowing content and maintain a clean and functional design for your web pages. Experiment with different values to find the best fit for your layout and design requirements.

💡 Best Practices

✅ Do

  • Use auto for scrollable content areas
  • Set width or height on overflow containers
  • Use hidden for image crops and clipped cards
  • Try overflow-x and overflow-y for axis control
  • Test overflow on mobile screen sizes

❌ Don’t

  • Hide important text with hidden without another way to access it
  • Use scroll everywhere when auto is enough
  • Expect overflow to work without size constraints on the box
  • Forget keyboard access inside scrollable regions
  • Confuse overflow with text wrapping (word-break, etc.)

Key Takeaways

Knowledge Unlocked

Five things to remember about overflow

Use these points when content exceeds its container.

5
Core concepts
02

Default visible

Show outside box.

Default
📝 03

Four Values

visible to auto.

Values
🔄 04

auto Scroll

Most common use.

Use case
05

overflow-x/y

Per-axis control.

Companion

❓ Frequently Asked Questions

overflow controls what happens when content is too big for its container, such as showing scrollbars or clipping extra content.
The default value is visible, which means overflowing content is shown outside the container.
scroll always shows scrollbars, while auto adds scrollbars only when content actually overflows.
Use hidden when you want to clip content that exceeds the container and do not want scrollbars.
Yes. They control horizontal and vertical overflow separately, while overflow is a shorthand for both axes.

Practice in the Live Editor

Open the HTML editor and experiment with visible, hidden, scroll, and auto.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful