CSS overflow-y Property (2025)

❮ Prev Next ❯

The overflow-y property specifies whether the content should be hidden, visible or scrolls vertically when the content overflows the element’s top and bottom edges. This property is one of the CSS3 properties.

The overflow-y property has four main values: visible, hidden, auto and scroll.

If the value of overflow-y is set to visible, the value of overflow-x, by default, will be set to visible. If the value of overflow-y is set to scroll, auto, or hidden, the value of overflow-x will be set to auto.

Initial Value visible
Applies to Block-containers, flex containers and grid containers.
Inherited No.
Animatable No.
Version CSS3
DOM Syntax object.style.overflowY = "auto";

The overflow-x property can be used to define clipping the right and left sides.

overflow-y: visible | hidden | scroll | auto | initial | inherit;

Example of the overflow-y property:

<!DOCTYPE html><html> <head> <title>Title of the document</title> <style> div.scroll { background-color: #1c87c9; color: #fff; height: 60px; width: 200px; overflow-y: scroll; } </style> </head> <body> <h2>Overflow-y property example</h2> <h3>Overflow-y: scroll</h3> <div class="scroll">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div> </body></html>

Result

CSS overflow-y Property (1)

Example of the overflow-y property with the "visible" value:

<!DOCTYPE html><html> <head> <title>Title of the document</title> <style> div.visible { background-color: #8ebf42; color: #666; height: 40px; width: 200px; overflow-y: visible; } </style> </head> <body> <h2>Overflow-y property example</h2> <h3>Overflow-y: visible</h3> <div class="visible">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div> </body></html>

Try it Yourself »

Example of the overflow-y property with the "hidden" value:

<!DOCTYPE html><html> <head> <title>Title of the document</title> <style> div.hidden { background-color: #1c87c9; color: #fff; height: 60px; width: 200px; overflow-y: hidden; } </style> </head> <body> <h2>Overflow-y property example</h2> <h3>Overflow-y: hidden</h3> <div class="hidden">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div> </body></html>

Try it Yourself »

Example of the overflow-y property with the "auto" value:

<!DOCTYPE html><html> <head> <title>Title of the document</title> <style> div.auto { background-color: #1c87c9; color: #fff; height: 60px; width: 200px; overflow-y: auto; } </style> </head> <body> <h2>Overflow-y property example</h2> <h3>Overflow-y: auto</h3> <div class="auto">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div> </body></html>

Try it Yourself »

Example of the overflow-y property with all the values:

<!DOCTYPE html><html> <head> <title>Title of the document</title> <style> div.scroll { background-color: #8ebf42; height: 70px; width: 150px; overflow-y: scroll; } div.hidden { background-color: #8ebf42; height: 70px; width: 150px; overflow-y: hidden; } div.auto { background-color: #8ebf42; height: 70px; width: 150px; overflow-y: auto; } div.visible { background-color: #8ebf42; height: 70px; width: 150px; overflow-y: visible; } </style> </head> <body> <h2>Overflow-y property example</h2> <h3>overflow-y: scroll</h3> <div class="scroll"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book </div> <h3>overflow-y: hidden</h3> <div class="hidden"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </div> <h3>overflow-y: auto</h3> <div class="auto"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </div> <h3>overflow-y: visible</h3> <div class="visible"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </div> </body></html>

Try it Yourself »

Values

Value Description Play it
visible The content is not clipped and renders outside the padding box's top and bottom edges. This is the default value of this property.Play it »
hidden The content is clipped to fit vertically in the padding box. No scrollbar is added.Play it »
scroll The content is clipped to fit vertically in the padding box. The scrollbar is added to see the rest of the content.Play it »
auto The content is clipped to fit vertically in the padding box. Depends on the browser. If content overflows, scrollbar is added.Play it »
initial Makes the property use its default value.Play it »
inherit Inherits the property from its parents element.

Browser support

CSS overflow-y Property (2) CSS overflow-y Property (3) CSS overflow-y Property (4) CSS overflow-y Property (5) CSS overflow-y Property (6)
1.0+ 12.0+ 1.5+ 3.0+ 9.5+

What does the overflow-y property in CSS do?

CSS overflow-y Property (7)

Correct!

CSS overflow-y Property (8)

Incorrect!

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

  • CSS Basics

❮ Prev Next ❯

  • CSS overflow Property
  • CSS overflow-x Property
  • CSS text-overflow Property
  • CSS white-space Property
  • CSS clip Property
  • CSS display Property
  • How to Hide Scrollbars with CSS
  • How to Make a Div Vertically Scrollable
  • How to Make Scrollbar Visible Only when Necessary
  • How to Prevent Scrollbar from Repositioning Web Page
  • How to Create an HTML Table with a Fixed Left Column and Scrollable Body
  • How to Make a Fixed Page Header Not Overlap In-Page Anchors

Sorry about that

Thanks for your feedback!

Thanks for your feedback!

Do you find this helpful?

CSS overflow-y Property (2025)

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Barbera Armstrong

Last Updated:

Views: 6417

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Barbera Armstrong

Birthday: 1992-09-12

Address: Suite 993 99852 Daugherty Causeway, Ritchiehaven, VT 49630

Phone: +5026838435397

Job: National Engineer

Hobby: Listening to music, Board games, Photography, Ice skating, LARPing, Kite flying, Rugby

Introduction: My name is Barbera Armstrong, I am a lovely, delightful, cooperative, funny, enchanting, vivacious, tender person who loves writing and wants to share my knowledge and understanding with you.