The Style overflowY property in HTML DOM is used to specify the behavior of the content when it overflows an element’s top and bottom edges. The content may be hidden, shown or a scrollbar according to the value.
Syntax:
- It returns the overflowY property.
object.style.overflowY
- It is used to set the overflowY property.
object.style.overflowY = "scroll|hidden|visible|auto|initial|inherit"
Property Values:
- scroll: The content is clipped to fit the element box and a scrollbar is provided help scroll the extra overflowed content. The scrollbar here is added even if the content is not clipped.
Example:
<!DOCTYPE html><html><head><title>DOM Style overflowY Property</title><style>.content {background-color: lightgreen;height: 150px;width: 200px;overflow-y: hidden;}button {margin-top: 60px;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>DOM Style overflowY Property</b><p>The overflowY property specifies thebehavior of content when it overflowsa block-level element’s top andbottom edges.</p><divclass="content">GeeksforGeeks is a computer science portalwith a huge variety of well written andexplained computer science and programmingarticles, quizzes and interview questions.<br>The portal also has dedicated GATEpreparation and competitive programmingsections.</div><buttononclick="myGeeks()">Change overflowY</button><!-- script to create overflowY --><script>function myGeeks() {elem = document.querySelector('.content');elem.style.overflowY = 'scroll';}</script></body></html>chevron_rightfilter_noneOutput:
Before click on the button:

After click on the button:

- hidden: The content is clipped and hidden to fit the element. No scrollbars are provided when using this value.
Example:
<!DOCTYPE html><html><head><title>DOM Style overflowY Property</title><style>.content {background-color: lightgreen;height: 150px;width: 200px;}button {margin-top: 60px;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>DOM Style overflowY Property</b><p>The overflowY property specifies thebehavior of content when it overflowsa block-level element’s top andbottom edges.</p><divclass="content">GeeksforGeeks is a computer science portalwith a huge variety of well written andexplained computer science and programmingarticles, quizzes and interview questions.<br>The portal also has dedicated GATEpreparation and competitive programmingsections.</div><buttononclick="myGeeks()">Change overflowY</button><!-- script to create overflowY --><script>function myGeeks() {elem = document.querySelector('.content');elem.style.overflowY = 'hidden';}</script></body></html>chevron_rightfilter_noneOutput:
Before click on the button:

After click on the button:

- visible: The content is not clipped and may overflow out to the top or bottom of the containing element.
Example:
<!DOCTYPE html><html><head><title>DOM Style overflowY Property</title><style>.content {background-color: lightgreen;height: 150px;width: 200px;overflow-y: hidden;}button {margin-top: 60px;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>DOM Style overflowY Property</b><p>The overflowY property specifies thebehavior of content when it overflowsa block-level element’s top and bottomedges.</p><divclass="content">GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. <br>The portalalso has dedicated GATE preparationand competitive programming sections.</div><buttononclick="myGeeks()">Change overflowY</button><!-- script to use oveflowY property --><script>function myGeeks() {elem = document.querySelector('.content');elem.style.overflowY = 'visible';}</script></body></html>chevron_rightfilter_noneOutput:
Before click on the button:

After click on the button:

- auto: The behavior of auto depends on the content and scrollbars are added only when the content overflows.
Example:
<!DOCTYPE html><html><head><title>DOM Style overflowY Property</title><style>.content {background-color: lightgreen;height: 150px;width: 200px;}button {margin-top: 60px;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>DOM Style overflowY Property</b><p>The overflowY property specifies thebehavior of content when it overflowsa block-level element’s top and bottomedges.</p><divclass="content">GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. <br>The portalalso has dedicated GATE preparationand competitive programming sections.</div><buttononclick="myGeeks()">Change overflowY</button><!-- script to use oveflowY property --><script>function myGeeks() {elem = document.querySelector('.content');elem.style.overflowY = 'auto';}</script></body></html>chevron_rightfilter_noneOutput:
Before click on the button:

After click on the button:

- initial: It sets the style overflowY property to its default value.
Example:
<!DOCTYPE html><html><head><title>DOM Style overflowY Property</title><style>.content {background-color: lightgreen;height: 150px;width: 200px;overflow-y: scroll;}button {margin-top: 60px;}</style></head><body><h1style="color: green">GeeksforGeeks</h1><b>DOM Style overflowY Property</b><p>The overflowY property specifies thebehavior of content when it overflowsa block-level element’s top and bottomedges.</p><divclass="content">GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. <br>The portalalso has dedicated GATE preparationand competitive programming sections.</div><buttononclick="myGeeks()">Change overflowY</button><!-- script to use oveflowY property --><script>function myGeeks() {elem = document.querySelector('.content');elem.style.overflowY = 'initial';}</script></body></html>chevron_rightfilter_noneOutput:
Before click on the button:

After click on the button:

- inherit: This inherits the property from its parent.
Example:
<!DOCTYPE html><html><head><title>DOM Style overflowY Property</title><style>#parent {/* setting the parent divto 'auto' */overflow-y: auto;}.content {background-color: lightgreen;height: 150px;width: 200px;}button {margin-top: 60px;}</style></head><body><h1style="color: green;">GeeksforGeeks</h1><b>DOM Style overflowY Property</b><p>The overflowY property specifies thebehavior of content when it overflowsa block-level element’s top and bottomedges.</p><divid="parent"><divclass="content">GeeksforGeeks is a computer scienceportal with a huge variety of wellwritten and explained computer scienceand programming articles, quizzes andinterview questions. <br>The portalalso has dedicated GATE preparation andcompetitive programming sections.</div></div><buttononclick="myGeeks()">Change overflowY</button><!-- script to set style overflowY property --><script>function myGeeks() {elem = document.querySelector('.content');elem.style.overflowY = 'inherit';}</script></body></html>chevron_rightfilter_noneOutput:
Before click on the button:

After click on the button:

Supported Browsers: The browser supported by DOM style overflowY property are listed below:
- Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
Recommended Posts:
- HTML | DOM Style backgroundClip Property
- HTML | DOM Style borderTop Property
- HTML | DOM Style columnGap Property
- HTML | DOM Style boxSizing Property
- HTML | DOM Style borderImageSource Property
- HTML | DOM Style wordBreak Property
- HTML | DOM Style pageBreakBefore Property
- HTML | DOM Style borderImageOutset Property
- HTML | DOM Style maxHeight Property
- HTML | DOM Style columnRuleWidth Property
- HTML | DOM Style transitionTimingFunction property
- HTML | DOM Style zIndex Property
- HTML | DOM Style borderTopLeftRadius Property
- HTML | DOM Style order Property
- HTML | DOM Style minWidth Property
- HTML | DOM Style visibility Property
- HTML | DOM Style animationTimingFunction Property
- HTML | DOM Style tabSize Property
- HTML | DOM Style backgroundColor Property
- HTML | DOM Style columnRule 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.


