CSS background-color Property

CSS background-color Property


CSS background-color Property
The background-color property sets the background color of an element using a color value or through keywords, such as transparent, inherit or initial.
This property sets an element’s background color. A wide variety of color values.
Syntax -
background-color: color | transparent | inherit
Now we will see the values -
Now we will see Example -
Example -
Output - 
Example - Using hex color values-
Output -
Example - Using rgb value -
Output -
Example - Using hsl value -
Output -
1. Background-Image 
The background-image property is used to specify a background image to be applied to all matched elements.
By default, this image is tiled to cover the entire element, excluding the margin. 
Syntax - 
We can apply background image using the following syntax - 
background-mage : url(image.png)

1. background keyword

2. With hyphen

3. image keyword 

4. Colon

Now setting url of image inside parentheses of url() function

Now we will see Examples - 
Example 1 -
Output - 
Example 2 -  We can also add image as the background of paragraph as well
Output -