Tillitsdone
down Scroll to discover

CSS Overflow-y Managing Vertical Content Overflow

Discover the CSS overflow-y property for managing vertical content overflow.

Learn about its use cases, available options like visible, hidden, scroll, auto, and clip, and how to implement them effectively.
thumbnail

overflow-y Property in CSS

The overflow-y property in CSS controls how content is displayed when it overflows the vertical boundaries of an element. It can clip the content, hide it, or add scroll bars, depending on the value assigned. This property is essential for web developers to manage content overflow effectively.

Syntax

The syntax for the overflow-y property is simple:

overflow-y: value;

You can use the following keyword values:

  • visible: Content is visible outside the element’s boundaries.
  • hidden: Content is clipped and invisible.
  • clip: Content is clipped at the element’s edge, no scrolling allowed.
  • scroll: Always shows scroll bars.
  • auto: Shows scroll bars only if the content overflows.

Additionally, you can use global values like inherit, initial, revert, revert-layer, and unset.

Values

The overflow-y property supports several values:

  • visible: Content is not clipped and can overflow.
  • hidden: Content is clipped and hidden.
  • clip: Content is clipped, no scrolling.
  • scroll: Always shows scroll bars.
  • auto: Shows scroll bars if content overflows.

Global values:

  • inherit: Inherits value from the parent element.
  • initial: Sets to default value (visible).
  • revert: Resets to inherited value.
  • revert-layer: Resets to inherited value if not specified at a lower layer.
  • unset: Resets to default value if not inherited.

Examples

Here are some examples to demonstrate the overflow-y property:

HTML

<ul>
<li>
<code>overflow-y:hidden</code> — hides the text outside the box
<div id="div1">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</li>
<li>
<code>overflow-y:scroll</code> — always adds a scrollbar
<div id="div2">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</li>
<li>
<code>overflow-y:visible</code> — displays the text outside the box if needed
<div id="div3">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</li>
<li>
<code>overflow-y:auto</code> — adds a scrollbar only if the content overflows
<div id="div4">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
velit esse cillum dolore eu fugiat nulla pariatur.
</div>
</li>
</ul>

CSS

div {
border: 1px solid black;
width: 250px;
height: 100px;
}
#div1 {
overflow-y: hidden;
margin-bottom: 12px;
}
#div2 {
overflow-y: scroll;
margin-bottom: 12px;
}
#div3 {
overflow-y: visible;
margin-bottom: 12px;
}
#div4 {
overflow-y: auto;
margin-bottom: 12px;
}

Formal Definition

The overflow-y property is formally defined in the CSS Overflow Module Level 3.

| Initial value | visible | | Applies to | Block-containers, flex containers, and grid containers | | Inherited | no | | Computed value | As specified, except with visible/clip computing to auto/hidden respectively if one of overflow-x or overflow-y is neither visible nor clip | | Animation type | discrete |

Formal Syntax

overflow-y = visible | hidden | clip | scroll | auto
  • visible: Content is not clipped and may be visible outside the element’s padding box.
  • hidden: Content is clipped to fit within the element’s padding box.
  • clip: Content is clipped at the element’s overflow clip edge.
  • scroll: Content is clipped and scroll bars are always displayed.
  • auto: Content is clipped and scroll bars are displayed if the content overflows.

Browser Compatibility

The overflow-y property in CSS is widely supported across modern web browsers. Here’s a quick overview:

BrowserVersionRelease Date
Chrome1.0December 2008
Firefox1.0November 2004
Internet Explorer4.0September 1997
Edge12.0July 2015
Opera7.0January 2003
Safari1.0June 2003

Ensuring Compatibility

To ensure that the overflow-y property works consistently across all browsers, test your web designs on multiple platforms and devices. This helps identify any potential issues with older browser versions.

See Also

To further enhance your knowledge and skills in managing content overflow, consider checking out these related properties and resources:

Related CSS Properties

  • [clip]WebsiteUrl: Defines the visible portion of an element.
  • [display]WebsiteUrl: Specifies the display behavior of an element.
  • [text-overflow]WebsiteUrl: Defines how overflowed content that is not displayed is signaled to the user.
  • [white-space]WebsiteUrl: Specifies how white-space inside an element is handled.

Related Resources

  • [CSS Overflow Module Level 3]WebsiteUrl: The official specification for the CSS overflow properties.
  • [CSS Overflow]WebsiteUrl: An overview of the CSS overflow module.
  • [CSS Building Blocks: Overflowing Content]WebsiteUrl: A comprehensive guide to understanding and managing overflowing content.

Additional Learning

  • [MDN Web Docs]WebsiteUrl: A comprehensive resource for web developers.
  • [W3C CSS Specifications]WebsiteUrl: The official specifications and recommendations for CSS.
icons/css-4.svg CSS Blogs
CSS3 is the latest version of Cascading Style Sheets, offering advanced styling features like animations, transitions, shadows, gradients, and responsive design.
css_property_cover/css-property-anchor-name.png CSS Anchor-Name Enhancing Web Layouts with Anchors Discover the CSS anchor-name property, a powerful tool for defining elements as anchors and creating dynamic, responsive web layouts. Learn about its use cases, available options, and how to effectively implement it in your projects. css_property_cover/css-property-inset.png CSS Inset Simplify Element Positioning Learn how to use the CSS inset property to easily set the top, right, bottom, and left offsets of an element. Discover available options, examples, and browser compatibility. css_property_cover/css-property-border-inline-width.png CSS border-inline-width Manage Logical Border Widths CSS border-inline-width lets you manage the width of logical inline borders for flexible and responsive designs. Use length values, keywords, and global values. css_property_cover/css-property-animation-fill-mode.png CSS Animation-Fill-Mode Control Animation Styles Learn how to use the CSS animation-fill-mode property to control the styles of elements before and after animations. Discover available options like forwards, backwards, both, and more. css_property_cover/css-property-font-variant-position.png CSS Font-Variant-Position Enhance Typography with Superscript and Subscript Discover the CSS font-variant-position property for controlling superscript and subscript glyphs. Learn about its use cases, available options like 'normal', 'sub', and 'super', and how to incorporate it into your web design projects for improved typography. css_property_cover/css-property-inset-inline.png CSS Inset-Inline Master Element Positioning Discover the CSS inset-inline property for precise control over element positioning in the inline direction. Learn about available options, practical examples, and browser compatibility.
icons/logo-tid.svg

Talk with CEO

Ready to bring your web/app to life or boost your team with expert Thai developers?
Contact us today to discuss your needs, and let’s create tailored solutions to achieve your goals. We’re here to help at every step!
🖐️ Contact us
Let's keep in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.