HTML | DOM Style padding Property Last Updated : 05 Jun, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The Style padding property is used for setting or returning the padding of an element. The Style padding property can be used in 4 different ways : div {padding: 30px} -In this case, all the four sides have a padding of 30px.div {padding: 100px 50px} -In this case, the top and bottom padding will be 100px, left and right padding will be 50px.div {padding: 10px 20px 50px} -In this case, the top padding will be 10px, left and right padding will be 20px, bottom padding will be 50px.div {padding: 100px 10px 20px 40px} -In this case, the top padding will be 100px, right padding will be 10px, bottom padding will be 20px, left padding will be 40px. Syntax: To get the property value:object.style.paddingTo set the property value:object.style.padding = "%|length|initial|inherit" Return Values: It returns a string value, which represents the padding of an element. Property values: % : It is used to define the padding in % of the width of the parent element.length : It is used to define the padding in length units.initial : It is used to set this property to its default value.inherit : It is used to inherit this property from its parent element. Below program illustrates the Style padding property : Example 1: Setting the padding{30px} for a <div> element: html <!DOCTYPE html> <html> <head> <title>Style padding Property in HTML</title> <style> #samplediv { border: 1px solid green; } h1 { color: green; } h2 { font-family: Impact; } body { text-align: center; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>Style padding Property</h2> <br> <div id="samplediv">Geeksforgeeks</div> <p>For setting the padding, double click the "Set Padding" button: </p> <br> <button ondblclick="padding()"> Set Padding </button> <script> function padding() { document.getElementById("samplediv") .style.padding = "30px"; } </script> </body> </html> Output: Before clicking the button: After clicking the button: Example 2: Setting the padding{100px 50px} for a <div> element: html <!DOCTYPE html> <html> <head> <title>Style padding Property in HTML</title> <style> #samplediv { border: 1px solid green; } h1 { color: green; } h2 { font-family: Impact; } body { text-align: center; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>Style padding Property</h2> <br> <div id="samplediv">Geeksforgeeks</div> <p>For setting the padding, double click the "Set Padding" button: </p> <br> <button ondblclick="padding()">Set Padding </button> <script> function padding() { document.getElementById("samplediv") .style.padding = "100px 50px"; } </script> </body> </html> Output: Before clicking the button: After clicking the button: Example 3: Setting the padding{10px 20px 50px} for a <div> element: html <!DOCTYPE html> <html> <head> <title>Style padding Property in HTML</title> <style> #samplediv { border: 1px solid green; } h1 { color: green; } h2 { font-family: Impact; } body { text-align: center; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>Style padding Property</h2> <br> <div id="samplediv">Geeksforgeeks</div> <p>For setting the padding, double click the "Set Padding" button: </p> <br> <button ondblclick="padding()"> Set Padding </button> <script> function padding() { document.getElementById("samplediv") .style.padding = "10px 20px 50px"; } </script> </body> </html> Output: Before clicking the button: After clicking the button: Example 4: Setting the padding{ 100px 10px 20px 40px} for a <div> element: html <!DOCTYPE html> <html> <head> <title>Style padding Property in HTML</title> <style> #samplediv { border: 1px solid green; } h1 { color: green; } h2 { font-family: Impact; } body { text-align: center; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>Style padding Property</h2> <br> <div id="samplediv">Geeksforgeeks</div> <p>For setting the padding, double click the "Set Padding" button: </p> <br> <button ondblclick="padding()"> Set Padding </button> <script> function padding() { document.getElementById("samplediv") .style.padding = "100px 10px 20px 40px"; } </script> </body> </html> Output:Before clicking the button: After clicking the button: Supported Browsers: Google Chrome 1 and aboveEdge 12 and aboveInternet Explorer 4 and aboveFirefox 1 and aboveOpera 3.5 and aboveApple Safari 1 and above Comment More infoAdvertise with us Next Article HTML DOM Style textDecorationStyle Property S Shubrodeep Banerjee Follow Improve Article Tags : JavaScript HTML-DOM HTML-Property Similar Reads HTML DOM ownerDocument Property The ownerDocument property returns the top-level document object of the node. Here, the owner document of the node is returned as the document object. It is a read-only property. Syntax: node.ownerDocument; Properties: nodeName property: It returns the name of the specified node. If the node is an e 2 min read HTML | DOM Style transitionDelay Property The transitionDelay property in HTML DOM is used to specify the time in seconds or milliseconds when execution of transition starts. The delay refers to the time, which to be waited before starting the transition effect. Syntax: It returns the transitionDelay property.object.style.transitionDelayIt 3 min read HTML DOM Style textDecorationStyle Property The Style textDecorationStyle property in HTML DOM is used to set the decoration of text with different kinds of lines. It can display the line in various styles like a single line, double line, wavy, etc. By using this property, we can display the line in a specified style. Syntax:Â Â It returns the 2 min read HTML | DOM Style listStyle Property The Style listStyle Property in HTML DOM used to set up to three list properties namely list-style-typelist-style-positionlist-style-image Syntax: It returns the listStyle property.object.style.listStyleIt used to set the listStyle property.object.style.listStyle = "type position image|initial|inher 2 min read HTML | DOM Style outlineStyle Property The Style outlineStyle property in HTML DOM is used to set or return the style of the outline around an element. Syntax: It is used to return the outlineStyle property.object.style.outlineStyleIt is used to set the outlineStyle property.object.style.outlineStyle = value Property Values: none: This i 2 min read HTML | DOM Heading Object The DOM Heading Object is used to represent the HTML <Heading> elements. The Heading elements is accessed by getElementById().Properties: align: This element contains a align attribute which is used to sets or returns the alignment of the heading elements. Syntax: document.getElementById("ID") 1 min read HTML | DOM Ul Object The DOM Ul Object is used to represent the HTML <ul> element .the ul element is accessed by getElementById().Properties: compact: It is used to set or return whether the height of the unordered list would be render smaller than normal, or not. type: It is used to set or return the value of the 2 min read HTML | DOM Time Object The DOM Time Object is used to represent the HTML Time element . The Time element is accessed by getElementById().Properties: dateTime: It contains single attribute datetime which is used to set or return the date/time in a machine-readable form of the element. Syntax: document.getElementById("ID"); 2 min read HTML DOM insertAdjacentHTML() Method The DOM insertAdjacentHTML() method is used to insert a text as HTML file to a specified position. This method is used to change or add text as HTML. Syntax : node.insertAdjacentHTML(specify-position, text-to-enter) Return Value : This will return the page with the specified change. There are four l 2 min read HTML DOM | Style pageBreakAfter Property The Style pageBreakAfter property is used for setting or returning the page-break behavior after an element in printing or print preview. The Style pageBreakAfter property does not affect the absolutely positioned elements. Syntax : To get the property: object.style.pageBreakAfter To set the propert 2 min read Like