CSS background color is used to set the color of background of an HTML element.
Syntax
1 |
background-color: enter color code here; |
1 2 3 4 5 6 7 8 9 |
<style> .div-bg-color{ background-color:red; color:#fff; } </style> <div class="div-bg-color"> <p>This is the HTML paragraph to show background color property of CSS.</p> </div> |
Output
This is the HTML paragraph to show background color property of CSS.
CSS background color values list
Sr. No. | value | Description |
---|---|---|
1 | hex color codes | Used to give color code in hex value format. The value for this is #fff, #000 etc. |
2 | rbga color codes | Used to give color code in rbga() format. The value for this can be rgba(255, 0, 0, 0.48), rgba(111, 66, 66, 0.48) etc. |
3 | color name | Used to give color name. The value for this can be red, blue etc. |
4 | transparent | Used to make a transparent background of an HTML element transparent. The value for this is transparent. |
5 | initial | Used to define as the property initial value. |
6 | inherit | Used to define the computed value of property on the elements parent. |
7 | unset | Used to set all the properties to their parent value if inheritable. |