HTML DOM insertAdjacentElement() Method Last Updated : 13 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The insertAdjacentElement() method inserts the specified element at the specified position. The legal values for this position are. afterbeginafterendbeforebeginbeforeend Syntax: node.insertAdjacentElement(position, element) Parameters: This method requires 2 parameters. position: A position relative to the element. The legal values are :-afterbegin: Just inside the element, before its first child.afterend: After the element itself.beforebegin: Before the element itself.beforeend: Just inside the element, after its last child.element: The element you want to insert. Return Value: The element that was inserted, or null, if the insertion failed. Exceptions: If the specified position is not recognized or if the specified element is not a valid element. Example: HTML <!DOCTYPE html> <html> <head> <!--script to insert specified element to the specified position--> <script> function insadjele() { var s = document.getElementById("d1"); var h = document.getElementById("head3"); h.insertAdjacentElement("afterend", s); } </script> </head> <body> <h1> Welcome To GeeksforGeeks</h1> <div id="d1">div element</div> <h3 id="head3">header element</h3> <p>Click the button to insert div element after the header element</p> <button onclick="insadjele()">Insert element</button> </body> </html> Output: Before clicking insert element button: After clicking insert element button: Supported Browsers: The browser supported by DOM insertAdjacentElement() Method are listed below: Google Chrome 1 and aboveEdge 17 and aboveFirefox 48 and aboveOpera 8 and aboveInternet Explorer 5 and aboveSafari 3 and above Comment More infoAdvertise with us P ProgrammerAnvesh Follow Improve Article Tags : Web Technologies HTML HTML-DOM HTML-Methods Similar Reads HTML | DOM Style animationFillMode Property The DOM style animationFillMode property is used to specify the style of an element when the animation is not playing or when an animation is finished or when there is a delay in animation. The animationFillMode property can override the default behavior of CSS animations by which CSS animations aff 3 min read 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 Like