HTML DOM Style backgroundColor Property Last Updated : 30 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The backgroundColor property in HTML DOM is used to set or return the background-color of an element. Syntax: object.style.backgroundColorIt returns the background color of an element.object.style.backgroundColor ="color|transparent|initial|inherit"It is used to set the background color of an element. Parameter: There are four parameters accepted by backgroundColor property color: This property holds the background color.transparent: By default the background color is transparent.initial: Set this property to its defaultinherit: Inherits the property from its parent element Return Values: It returns a string value, which represents the background color. Example 1: In this example, we will use the backgroundColor property in HTML DOM. HTML <!DOCTYPE html> <html> <head> <title> Style backgroundColor Property </title> </head> <body style="text-align:center"> <h1 style="color:green;"> GeeksForGeeks </h1> <h2> Style backgroundColor Property </h2> <button type="button" onclick="geeks()"> Submit </button> <script> /* script to set background color */ function geeks() { document.body.style.backgroundColor = "lightgreen"; } </script> </body> </html> Output: Example 2: In this example, we will use the backgroundColor property in HTML DOM. HTML <!DOCTYPE html> <html> <head> <title> Style backgroundColor Property </title> <style> #geeks { width: 250px; height: 100px; background-color: coral; } </style> </head> <body> <center> <h1 style="color:green;"> GeeksForGeeks </h1> <h2> DOM Style backgroundColor Property </h2> <button onclick="geeks()">Submit</button> <div id="geeks"> <h1>GeeksForGeeks</h1> </div> <script> function geeks() { document.getElementById("geeks").style.backgroundColor = "lightgreen"; } </script> </center> </body> </html> Output: Supported Browsers: The browser supported by DOM style backgroundColor Properties are listed below: Chrome 1.0 and aboveEdge 12 and aboveInternet Explorer 4.0 and aboveFirefox 1.0 and aboveSafari 1.0 and aboveOpera 3.5 and above Comment More infoAdvertise with us M manaschhabra2 Follow Improve Article Tags : Misc Web Technologies HTML HTML-DOM Practice Tags : Misc Similar Reads HTML DOM designMode Property The DOM designMode property in HTML is used to specify whether the document is editable or not. It can also be used to set the document editable. Syntax:Set: This property is used to set whether the document is editable or not.document.designMode = "on|off";Get: This property is used to return wheth 2 min read HTML DOM Style borderCollapse Property The DOM Style borderCollapse property in HTML is used to set or return whether the border of the table collapsed into a single border or not. Syntax: It is used to return the borderCollapse property.object.style.borderCollapse It is used to set borderCollapse property.object.style.borderCollapse = " 2 min read HTML DOM Style borderBottom Property The DOM style borderBottom property is used to set or return the three different border-bottom properties such as border-bottom-width, border-bottom-style, and border-bottom-color of an element. Syntax: It returns the borderBottom Property.object.style.borderBottomIt is used to set the borderBottom 2 min read HTML DOM Style color Property The DOM style color property is used to set or return the color of the text. Syntax: It is used to set the color property.object.style.colorIt is used to return the color property.object.style.color = "color|initial|inherit" Return Values: It returns a string value that represents a text-color of an 1 min read HTML DOM cookie Property Almost every website stores cookies (small text files) on the user's computer for recognition and to keep track of his preferences. DOM cookie property sets or gets all the key/value pairs of cookies associated with the current document.Getting all the Cookies: The document.cookie method returns a s 3 min read HTML DOM isId Property The isId Property contains a boolean value that returns a true if the Element has an attribute type of ID, otherwise, it returns a false or undefined value. This Property is used for read-only. Syntax: attribute.isId Return Value: It returns a Boolean value i.e. true if the attribute type is ID, els 2 min read HTML DOM createElement() Method In an HTML document, the document.createElement() is a method used to create the HTML element. The element specified using elementName is created or an unknown HTML element is created if the specified elementName is not recognized. Syntaxlet element = document.createElement("elementName");In the abo 2 min read HTML DOM hasFocus() Method In HTML document, the document.hasfocus() the method is used for indicating whether an element or document has the focus or not. The function returns a true value if the element is focused otherwise false is returned. This method can be used to determine whether the active element is currently in fo 2 min read HTML DOM removeNamedItem() Method The removeNamedItem() method in HTML is used to remove the node with the specified name in a namednode object.Syntax: namednode.removeNamedItem( nodename )Parameter: The removeNamedItem() contains only one parameter nodename that is described below. nodename: This method accepts a single parameter n 2 min read HTML DOM domain Property The domain Property is used to return the domain name of the website server that is loaded or running in the current document. Syntax:document.domain Note: This property has been DEPRECATED and is no longer recommended.Return Value: It returns the string value representing the website's domain name 2 min read Like