HTML DOM setAttributeNode() Method Last Updated : 15 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The setAttributeNode() method in HTML DOM is used to add the specified attribute node to an element. If the specified attribute is already present, then this method replaces it. Syntax: element.setAttributeNode(name) Parameter: Only one parameter is accepted name.Where the name is the attribute node to be added. It is the required field. Return Value: This method returns an attribute object which represents the replaced attribute node otherwise it returns null. Example: In this example, we will use the setAttributeNode() method. HTML <!DOCTYPE html> <html> <head> <title> HTML DOM setAttributeNode Method </title> <style> .gfg { color: green; } </style> </head> <body style="text-align: center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h2> DOM setAttributeNode Method </h2> <p id="p"> A computer science portal for geeks. </p> <button onclick="Geeks()"> Click Here! </button> <script> function Geeks() { //Get the paragraph to add attribute. let doc = document.getElementById("p"); //Creating a class attribute. let attr = document.createAttribute("class"); //Setting the value of class attribute. attr.value = "gfg"; //Adding class attribute to paragraph. doc.setAttributeNode(attr); } </script> </body> </html> Output: Supported Browsers: The browser supported by the setAttributeNode() method are listed below: Google Chrome 1Edge 12Internet Explorer 6Firefox 1Opera 12.1Safari 1 Comment More infoAdvertise with us V Vishal Chaudhary 2 Follow Improve Article Tags : Web Technologies HTML Web technologies HTML-DOM HTML-Methods +1 More Similar Reads HTML DOM Style borderBottomRightRadius Property The DOM borderBottomRightRadius property is used to select any element from the DOM tree and set the style of the radius of the bottom-right corner of its border. Syntax : It returns the borderBottomRightRadius Property.object.style.borderBottomRightRadiusIt is used to set the borderBottom property. 2 min read HTML | DOM Style borderBottomWidth Property The style borderBottomWidth property in HTML DOM is used to set or return the width of bottom border of an element. Syntax: It is used to return the width of bottom border.object.style.borderBottomWidthIt is used to set the width of the bottom border.border-bottom-width: "medium|thin|thick|length|in 2 min read HTML DOM Style animationDuration Property The Style animationDuration property in HTML DOM is used to set the time interval to complete one cycle of an animation. Syntax: It returns the animationDuration property.object.style.animationDurationIt sets the animationDuration property.object.style.animationDuration = "time|initial|inherit" Retu 3 min read HTML DOM offsetTop Property The DOM offsetTop property is used to return the top position which is relative to the top of the offsetParent element. Syntax: object.offsetTop Return Value: A number in the pixel unit represents the top position of the element. Example: In this example, we will use DOM offsetTop property HTML < 1 min read HTML DOM Style animationIterationCount Property The Style animationIterationCount property in HTML DOM is used to set or return how many times an animation should be played. Syntax: It is used to return the animationIterationCount property.object.style.animationIterationCountIt is used to set the animationIterationCount property.object.style.anim 2 min read HTML DOM WheelEvent deltaX Property The WheelEvent.deltaX property in HTML is used to return a positive double value when the web page is scrolled horizontally along the left or right direction. If the page is scrolled to the right it returns a positive value, and a negative double value when scrolled to the left, else it returns zero 1 min read HTML DOM offsetHeight Property The DOM offsetHeight property is used to return the layout height of an element as an integer. It is measured in pixels. It includes height, border, padding, and horizontal scrollbars but not margin. If the element is hidden then it returns 0. Syntax: element.offsetHeight Return Value: It returns th 2 min read HTML DOM Style borderColor Property The DOM Style borderColor property specifies the color of the element's border. It may be given explicitly, inherit from the parent or by default it will take the default value. Syntax: To get the border color property:object.style.borderColorTo set the border color property:object.style.borderColor 3 min read HTML DOM Style borderBottomStyle Property The style borderBottomStyle property in HTML DOM is used to set or return the style of the bottom border of an element. Syntax: It returns the style of the bottom border.object.style.borderBottomStyleIt sets the style of the bottom border.border-bottom-style: value; Property Values: none: It is the 2 min read HTML DOM Del Object The Del Object in HTML DOM is used to represent the HTML <del> element. The <del> element can be accessed by getElementById(). Object Properties: cite: It is used to set or return the value of the cite attribute of a deleted element.dateTime: It is used to sets or return the value of the 2 min read Like