Div Background Color

Inserting it to the body element you will have a full colored cover of the page.
Div background color. Rgba red green blue alpha the alpha parameter is a number between 0 0 fully transparent and 1 0 fully opaque. The below sections will guide you on how to create the effect. An rgba color value is specified with. The background color property is used to change the background color.
We will use the queryselector and addeventlistener method to select the element and then apply some math logic to change its background color. So if you do not specify the background color of a div it will display that of its parent element. You learned from our css colors chapter that you can use rgb as a color value in addition to rgb you can use an rgb color value with an alpha channel rgba which specifies the opacity for a color. The default background color of a div is transparent.
The background color of the div box can be easily changed using html css and javascript. Changing the background color of a div in this example we will change the background colors of the following divs. Example of setting a background color with the css background color property.