Last Updated : Jul 1, 2023
Depending on the backdrop colour, you can select multiple colour palettes for buttons, inputs, and other objects. The colour displayed in the backdrop of an element can be changed by changing different property.
- To begin, type <! DOCTYPE html> to indicate that the file is in HTML format to the web browser.
- The <html> element, on the other hand, is used to indicate that HTML content is about to begin.
- The information about web pages is now contained in the <head> tag. This tag uses the <title> element to provide a web page title. The <head> and <title> tags, for example, are paired tags. As a result, both have the closing tags </head> and </title>.
- You may also access the element by using the class's id or name. The getElementById() function can be used to get an element by its id. The getElementsByClassName() function can be used to get an element by its class name.
- The code above just affects the element with the id myID's background colour, not the entire body section. You can also use the colour code of different colours instead of the colour name to modify the background colour of an element.
- You'll see a button and some text in this code. When you push the button, the text's background colour changes to the specified colour.
- The </body> and </html> tags, respectively, close the <body> and <html> tags.
We've gone through all of the code with you step by step, including an example of using script and altering the background.