HTML DOM Style maxWidth Property Last Updated : 25 Aug, 2023 Comments Improve Suggest changes Like Article Like Report 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 | length | % | initial | inherit"Property Values: ValueDescriptionnoneDefault value without any limit on width of the elementlengthDefine width's maximum value in length unit%Define width's maximum value in % of the parent elementinitialSet property to its default valueinheritInherit from its parent elementReturn value: It return the maximum width of element. Example 1: This example Sets the width in length unit. html <!DOCTYPE html> <html> <head> <title>DOM Style maxWidth Property </title> <style> #GFG { color: white; width: 300px; background: green; margin: auto; } </style> </head> <body style="text-align: center;"> <h1 id="GFG"> GeeksforGeeks </h1> <h2>HTML DOM Style maxWidth Property</h2> <br> <button type="button" onclick="myGeeks()"> Click to change </button> <script> function myGeeks() { // Sets the width using length unit document.getElementById("GFG") .style.maxWidth = "220px"; } </script> </body> </html> Output: Example 2: This example Sets the width value in '%'. html <!DOCTYPE html> <html> <head> <title>DOM Style maxWidth Property </title> <style> #GFG { color: white; width: 22%; background: green; margin: auto; } </style> </head> <body style="text-align: center;"> <h1 id="GFG"> GeeksforGeeks </h1> <h2>HTML DOM Style maxWidth Property</h2> <br> <button type="button" onclick="myGeeks()"> Click to change </button> <script> function myGeeks() { // Sets the width using length unit document.getElementById("GFG") .style.maxWidth = "17%"; } </script> </body> </html> Output: Supported Browsers: The browser supported by HTML DOM Style maxWidth Property are listed below: Google Chrome 1 and aboveEdge 12 and aboveInternet Explorer 7 and aboveMozilla Firefox 1 and aboveOpera 4 and aboveSafari 1 and above Create Quiz Comment P PranchalKatiyar Follow 0 Improve P PranchalKatiyar Follow 0 Improve Article Tags : Web Technologies HTML HTML-DOM HTML-Property Explore HTML BasicsHTML Introduction4 min readHTML Editors4 min readHTML Basics7 min readStructure & ElementsHTML Elements4 min readHTML Attributes7 min readHTML Headings3 min readHTML Paragraphs3 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists3 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks2 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables9 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms4 min readHTML5 Semantics5 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List5 min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like