In CSS, we use the background-color
property to specify the background color of an element.
In the code snippet below, the entire color of the web page is set using the background-color
property.
The value of the background-color
property can be specified in three ways:
RGB values
e.g. rgb(250,0,0), rgb(0,250,0), etc.Hexadecimal(HEX) value
e.g. #FFFFFF, #000000, etc.color name
e.g. “white”, “red”, “black”, “blue”, etc.
The code snippet below sets the background color for the entire body
, <div>
, <h2>
and <p>
elements of the web page.
Free Resources