HTML | DOM Style margin Property Last Updated : 16 Jun, 2022 Comments Improve Suggest changes Like Article Like Report The DOM Style margin Property is used to sets or returns the margin of an element.We can set the different size of margins for individual sides(top, right, bottom, left).Margin properties can have following values: Length in cm, px, pt, etc.Width % of the element.Margin calculated by the browser: auto. Syntax: It is used to set the margin Property. object.style.margin = "%|length|auto|initial|inherit" It is used to get the margin Property. object.style.margin Property Values: ValueDescription%Define the length in percentage compare to parent element.lengthDefine the length in length unit.autoIt is default value.initialDefine the initial default value.inheritinherit from parent element. Return Value: It returns a string value which represent the top, right, bottom, left margin of an element.Example-1:Margin property set to four values 80px 40px 20px 90px that means top = 80px, right = 40px, bottom = 20px and left = 90px. html <html> <head> <title> HTML | DOM Style margin Property </title> <style> h1 { coor: green; } #GFG { border: 2px solid green; } </style> </head> <body> <center> <h1> GEEKSFORGEEKS </h1> <h2> DOM Style margin Property </h2> <p id="GFG"> Margin properties </p> <br> <BUTTON ONCLICK="Geeks()">Submit</BUTTON> <script> function Geeks() { document.getElementById("GFG").style.margin = "80px 40px 20px 90px"; } </script> </body> </html> Output : Before click on the button: After click on the button: Example-2: Change all four margin to a single margin margin: 25px; denotes top, right, bottom and left = 25px html <html> <head> <title> HTML | DOM Style margin Property </title> <style> h1 { coor: green; } #GFG { border: 2px solid green; margin: 60px 20px 90px 100px; } </style> </head> <body> <center> <h1> GEEKSFORGEEKS </h1> <h2> DOM Style margin Property </h2> <p id="GFG"> Margin properties </p> <br> <BUTTON ONCLICK="Geeks()">Submit</BUTTON> <script> function Geeks() { document.getElementById("GFG").style.margin = "25px"; } </script> </body> </html> Output: Before clicking on the button: After clicking on the button: Supported Browsers: The browser supported by DOM Style margin property are listed below: Google Chrome 1.0 and aboveEdge 12.0 and aboveInternet Explorer 3.0 and aboveFirefox 1.0 and aboveOpera 3.5 and aboveApple Safari 1.0 and above Comment More infoAdvertise with us Next Article HTML DOM isContentEditable Property M manaschhabra2 Follow Improve Article Tags : Misc Web Technologies HTML HTML-DOM Practice Tags : Misc Similar Reads HTML DOM nextSibling Property The nextSibling property returns the next node at the same tree level, providing a node object. It's read-only and navigates through sibling nodes within the document structure. Syntax: node.nextSiblingReturn value: Name Description Node The nextSibling property returns the next sibling node or null 2 min read HTML DOM isContentEditable Property The DOM isContentEditable property is used to return a boolean where true means the content of an element is editable and false represents content is not editable. This property is read-only. Syntax: Object.isContentEditable Return Value: This property returns a boolean value. true means that the co 1 min read HTML DOM implementation Property The DOM implementation property in HTML is used to return the DOMImplementation object associated with the current document. The DOMImplementation is the interface that represents a method providing the object which is not dependent on any particular document. Syntax: document.implementation Return 2 min read HTML DOM specified Property The DOM specified property is used to return the boolean value. It returns true if the element has a specified attribute, otherwise, it returns a false value if the element does not have a specific attribute. Syntax:attribute.specifiedReturn value: It returns the boolean value which represents wheth 2 min read HTML DOM offsetLeft Property The DOM offsetLeft property is used to return the left position in pixels. This position is relative to the left side of the offsetParent element. Syntax: element.offsetLeft Return Value: It returns the number representing the left position of the element in pixels. Example: In this example, we will 1 min read HTML DOM previousElementSibling Property The previousElementSibling property in HTML DOM is used to return the previous element of the same level as the given element. If no previous element is found on the same level then it returns null. It is a read-only property. It is similar to the previousSibling property but the difference is previ 2 min read HTML DOM childElementCount Property The DOM childElementCount property is used to count the number of child elements and return it. It counts only child elements except for text and comment nodes. Syntax: node.childElementCount Where a node is an object which represents the document or element. Return Value: It returns the number of c 1 min read HTML DOM nextElementSibling Property The nextElementSibling property is used to return the immediate next element of the specified element, in the same tree level or null if the specified element is the last one in the list. It is a read-only property. It differs from the nextSibling property as nextSibling returns the next sibling nod 2 min read HTML DOM focus() Method DOM focus() method is used to give focus to an element and also to remove the focus with the help of blur() method. We can apply focus to any element and enable it by doing some operation. For example, we can give focus to some text by clicking a button. Syntax: Object.focus() Example-1: HTML <!D 1 min read HTML DOM innerHTML Property The innerHTML property sets or returns the HTML content (inner HTML) of an element. It allows you to manipulate the inner content, including HTML tags, by assigning new HTML strings or retrieving existing content, making it useful for dynamic updates on web pages.SyntaxIt returns the innerHTML Prope 2 min read Like