HTML | DOM Style overflowX Property Last Updated : 02 Jun, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The Style overflowX property in HTML DOM is used to specify the behavior of the content when it overflows an element’s left and right edges. The content may be hidden, shown or a scrollbar according to the value. Syntax: It returns the overflowX property.object.style.overflowXIt is used to set the overflowX property.object.style.overflowX = "hidden|visible|scroll|auto|initial| inherit" Return Values: It returns a string value, which represents the overflow-x property of an element Property Values: hidden: The content is clipped and hidden to fit the element. No scrollbars are provided when using this value. Example: HTML <!DOCTYPE html> <html> <head> <title> DOM Style overflowX Property </title> <style> .content { background-color: lightgreen; height: 150px; width: 200px; white-space: nowrap; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b>DOM Style overflowX Property</b> <p> The overflowX property specifies the behavior of content when it overflows a block-level element’s left and right edges. </p> <div class="content"> GeeksforGeeks is a computer science portal with a huge variety of well written and<br> explained computer science and programming articles, quizzes and interview questions. <br>The portal also has dedicated GATE preparation and competitive programming sections. </div> <button onclick="setOverflow()"> Change overflowX </button> <!-- Script to set overflowX to hidden --> <script> function setOverflow() { elem = document.querySelector('.content'); elem.style.overflowX = 'hidden'; } </script> </body> </html> Output:Before clicking the button: After clicking the button: visible: The content is not clipped and may overflow out to the left or right of the containing element. Example: HTML <!DOCTYPE html> <html> <head> <title> DOM Style overflowX Property </title> <style> .content { background-color: lightgreen; height: 150px; width: 200px; white-space: nowrap; overflow-x: hidden; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b>DOM Style overflowX Property</b> <p> The overflowX property specifies the behavior of content when it overflows a block-level element’s left and right edges. </p> <div class="content"> GeeksforGeeks is a computer science portal with a huge variety of well written and<br> explained computer science and programming articles, quizzes and interview questions. <br>The portal also has dedicated GATE preparation and competitive programming sections. </div> <button onclick="setOverflow()"> Change overflowX </button> <!-- Script to set overflowX to visible --> <script> function setOverflow() { elem = document.querySelector('.content'); elem.style.overflowX = 'visible'; } </script> </body> </html> Output:Before clicking the button: After clicking the button: 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: HTML <!DOCTYPE html> <html> <head> <title> DOM Style overflowX Property </title> <style> .content { background-color: lightgreen; height: 150px; width: 200px; white-space: nowrap; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b>DOM Style overflowX Property</b> <p> The overflowX property specifies the behavior of content when it overflows a block-level element’s left and right edges. </p> <div class="content"> GeeksforGeeks is a computer science portal with a huge variety of well written and<br> explained computer science and programming articles, quizzes and interview questions. <br>The portal also has dedicated GATE preparation and competitive programming sections. </div> <button onclick="setOverflow()"> Change overflowX </button> <!-- Script to set overflowX to scroll --> <script> function setOverflow() { elem = document.querySelector('.content'); elem.style.overflowX = 'scroll'; } </script> </body> </html> Output:Before clicking the button: After clicking the button: auto: The behavior of auto depends on the content and scrollbars are added only when the content overflows. Example: HTML <!DOCTYPE html> <html> <head> <title> DOM Style overflowX Property </title> <style> .content { background-color: lightgreen; height: 150px; width: 200px; white-space: nowrap; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b>DOM Style overflowX Property</b> <p> The overflowX property specifies the behavior of content when it overflows a block-level element’s left and right edges. </p> <div class="content"> GeeksforGeeks is a computer science portal with a huge variety of well written and<br> explained computer science and programming articles, quizzes and interview questions. <br>The portal also has dedicated GATE preparation and competitive programming sections. </div> <button onclick="setOverflow()"> Change overflowX </button> <!-- Script to set overflowX to auto --> <script> function setOverflow() { elem = document.querySelector('.content'); elem.style.overflowX = 'auto'; } </script> </body> </html> Output:Before clicking the button: After clicking the button: initial: This is used to set this property to its default value. Example: HTML <!DOCTYPE html> <html> <head> <title> DOM Style overflowX Property </title> <style> .content { background-color: lightgreen; height: 150px; width: 200px; white-space: nowrap; /* Setting the overflow-x property to 'scroll' to observe the effect of initial */ overflow-x: scroll; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b>DOM Style overflowX Property</b> <p> The overflowX property specifies the behavior of content when it overflows a block-level element’s left and right edges. </p> <div class="content"> GeeksforGeeks is a computer science portal with a huge variety of well written and<br> explained computer science and programming articles, quizzes and interview questions. <br>The portal also has dedicated GATE preparation and competitive programming sections. </div> <button onclick="setOverflow()"> Change overflowX </button> <!-- Script to set overflowX to initial --> <script> function setOverflow() { elem = document.querySelector('.content'); elem.style.overflowX = 'initial'; } </script> </body> </html> Output:Before clicking the button: After clicking the button: inherit: It inherits the property from its parent element. Example: HTML <!DOCTYPE html> <html> <head> <title> DOM Style overflowX Property </title> <style> #parent { /* Setting the overflow-x property of the parent */ overflow-x: hidden; } .content { background-color: lightgreen; height: 150px; width: 200px; white-space: nowrap; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b>DOM Style overflowX Property</b> <p> The overflowX property specifies the behavior of content when it overflows a block-level element’s left and right edges. </p> <div id="parent"> <div class="content"> GeeksforGeeks is a computer science portal with a huge variety of well written and <br> explained computer science and programming articles, quizzes and interview questions. <br>The portal also has dedicated GATE preparation and competitive programming sections. </div> </div> <button onclick="setOverflow()"> Change overflowX </button> <!-- Script to use overflowX to inherit --> <script> function setOverflow() { elem = document.querySelector('.content'); elem.style.overflowX = 'inherit'; } </script> </body> </html> Output:Before clicking the button: After clicking the button: Supported Browsers: Chrome 1 and aboveEdge 12 and aboveInternet Explorer 5 and aboveFirefox 3.5 and aboveSafari 3 and aboveOpera 9.5 and above Comment More infoAdvertise with us Next Article HTML | DOM Style overflowY Property S sayantanm19 Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML | DOM Style overflow Property The Style overflow property in HTML DOM is used to specify the behavior of the content when it overflows the element box. The content may be hidden, shown or a scrollbar maybe shown according to the value. Syntax: It returns the overflow property.object.style.overflowIt is used to set the overflow p 6 min read HTML | DOM Style overflowY Property 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.overflowYIt is used to set the o 6 min read HTML DOM Style maxWidth Property The maxWidth property of HTML DOM sets/returns the maximum width of an element. The maxWidth property affects only block-level elements, absolute or fixed position elements. Syntax: It returns the maxWidth property.object.style.maxWidthIt sets the maxWidth Property.object.style.maxWidth = "none | le 2 min read HTML | DOM Style maxHeight Property The maxHeight property set/return the maximum height of an element. The maxHeight property affect only on block-level elements, absolute or fixed position elements. Syntax: It is used to set the maxHeight property:object.style.maxHeight = "none|length|%|initial|inherit"It is used to return the maxHe 2 min read HTML DOM | Style paddingLeft Property The Style paddingLeft property is used for setting or returning the left padding of an element. The padding property inserts the user desired space within the border of an element.Syntax : To get the property: object.style.paddingLeftTo set the property: object.style.left = "auto|length|%|initial|in 2 min read HTML DOM Style paddingLeft Property The Style paddingLeft property in HTML DOM is used to set or return the left padding of the element. Syntax: It returns the paddingLeft property. object.style.paddingLeftIt sets the paddingLeft Property. object.style.paddingLeft = "% | length | initial | inherit"Return value: It returns the string v 2 min read Like