CSS overflow-y Property
The overflow-y property of CSS specifies the behavior of content when it overflows a block-level element’s top and bottom edges. The content may be clipped, hidden or a scrollbar may be displayed accordingly based on the value assigned to the overflow-y property.
Syntax:
overflow-y: scroll | hidden | visible | auto
Values:
-
Scroll: If the value assigned to the property is “scroll” then the content is clipped to fit the element and a scrollbar is displayed by the browser to help scroll the overflowed content. The scrollbar is added regardless of the content being clipped.
Example:
<!DOCTYPE html><html><head><style>.content {background-color: lightgreen;height: 100px;width: 250px;overflow-y: scroll;}</style></head><body><h1>The overflow-y Property</h1><!-- Below paragraph doesnot have a fixed width or heightand has no overflow set. So, it will just take up thecomplete width of it's parent to fit the content --><p>The CSS overflow-y property specifies the behaviorof content when it overflows a block-level element’stop and bottom edges. The content may be clipped,hidden or a scrollbar may be displayed as specified.</p><h2>overflow-y: scroll</h2><!-- Below div element has fixed height and width and thusoverflow may occur. --><divclass="content">GeeksforGeeks is a computer science portal with ahuge variety of well written and explainedcomputer science and programming articles,quizzes and interview questions. The portal alsohas dedicated GATE preparation and competitiveprogramming sections.</div></body></html>chevron_rightfilter_noneOutput:

-
Hidden: On assigning “hidden” as the value to the property, the content is clipped to fit the element. No scrollbars are provided and the content is hidden.
Example:
<!DOCTYPE html><html><head><style>.content {background-color: lightgreen;height: 100px;width: 250px;overflow-y: hidden;}</style></head><body><h1>The overflow-y Property</h1><!-- Below paragraph doesnot have a fixed width or heightand has no overflow set. So, it will just take up thecomplete width of it's parent to fit the content --><p>The CSS overflow-y property specifies the behaviorof content when it overflows a block-level element’stop and bottom edges. The content may be clipped,hidden or a scrollbar may be displayed as specified.</p><h2>overflow-y: hidden</h2><!-- Below div element has fixed height and width and theoverflow is set as hidden, so the bottom contentoverflowing will be clipped --><divclass="content">GeeksforGeeks is a computer science portal with a hugevariety of well written and explained computer scienceand programming articles, quizzes and interview questions.The portal also has dedicated GATE preparation andcompetitive programming sections.</div></body></html>chevron_rightfilter_noneOutput:
-
Visible: If the value assigned to the “overflow-y” property is “visible” then the content is not clipped and may overflow out to the top or bottom of the containing element.
Example:<!DOCTYPE html><html><head><style>.content {background-color: lightgreen;height: 100px;width: 250px;overflow-y: visible;}</style></head><body><h1>The overflow-y Property</h1><!-- Below paragraph doesnot have a fixed width or heightand has no overflow set. So, it will just take up thecomplete width of it's parent to fit the content --><p>The CSS overflow-y property specifies the behaviorof content when it overflows a block-level element’stop and bottom edges. The content may be clipped,hidden or a scrollbar may be displayed as specified.</p><h2>overflow-y: visible</h2><!-- In the below div the overflowing content is visible --><divclass="content">GeeksforGeeks is a computer science portal with a hugevariety of well written and explained computer scienceand programming articles, quizzes and interviewquestions. The portal also has dedicated GATEpreparation and competitive programming sections.</div></body></html>chevron_rightfilter_noneOutput:
-
Auto: The behavior of auto depends on the content and scrollbars are added only when the content overflows, unlike that of the
scrollvalue where the scrollbar is added regardless of overflow.Example:
<!DOCTYPE html><html><head><style>.content {background-color: lightgreen;height: 100px;width: 250px;overflow-y: auto;}</style></head><body><h1>The overflow-y Property</h1><!-- Below paragraph doesnot have a fixed width or heightand has no overflow set. So, it will just take up thecomplete width of it's parent to fit the content --><p>The CSS overflow-y property specifies the behaviorof content when it overflows a block-level element’stop and bottom edges. The content may be clipped,hidden or a scrollbar may be displayed as specified.</p><h2>overflow-y: auto</h2><divclass="content">GeeksforGeeks is a computer science portal with a hugevariety of well written and explained computer scienceand programming articles, quizzes and interview questions.The portal also has dedicated GATE preparation andcompetitive programming sections.</div></body></html>chevron_rightfilter_noneOutput:
Supported Browsers: The browser supported by overflow-y property are listed below:
- Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
Recommended Posts:
- HTML | DOM Style overflowY Property
- CSS | transition-property Property
- CSS | right Property
- CSS | all Property
- CSS | top Property
- CSS | resize Property
- CSS | transition Property
- CSS | content Property
- CSS | align-self Property
- CSS | margin-right Property
- CSS | border-top Property
- CSS | max-width Property
- CSS | box-sizing Property
- CSS | min-height Property
- CSS | perspective Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



