To change background color of Div using CSS, you can set the background-color
style property for the div elements with the values like #FF5588
, Yellow
, rgb(80, 165, 201)
, etc.
The following is the typical CSS code to change background color of Div in HTML page using tag name div
.
div {
background-color: #FF5588;
}
div {
background-color: Yellow;
}
div {
background-color: rgb(80, 165, 201);
}
We shall go through some working examples on how to change background color of Div using CSS. In the following examples, you may change the value of background-color and Run the code to visually observe the changes made to the Div elements.
This is an example on how to change background color of Div using hex color.
You may edit the following code, and click on Run button.
This is an example on how to change background color of Div using color name.
You may edit the following code, and click on Run button.
This is an example on how to change background color of Div using rgb() function to specify color.
You may edit the following code, and click on Run button.