To change background color of heading using CSS, you can set the background-color
style property for the heading 2 elements with the values like #FF5588
, Yellow
, rgb(80, 165, 201)
, etc.
The following is the typical CSS code to change background color of heading in HTML page using tag name h2
.
h2 {
background-color: #FF5588;
}
h2 {
background-color: Yellow;
}
h2 {
background-color: rgb(80, 165, 201);
}
We shall go through some working examples on how to change background color of heading 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 Heading 2 elements.
This is an example on how to change background color of heading 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 heading 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 heading using rgb() function to specify color.
You may edit the following code, and click on Run button.