CSS Background-color

This property is used to set the background color of an element. The background of an element covers the total size, including the padding and border and excluding margin. It can be applied to all HTML elements.

Syntax

Let's discuss the possible values of this property.

  • color_name: It is used for defining the background color value or the color codes. It can be given by using the color name, hexadecimal value, or rgb() value.
  • transparent: It is the default value of this property, which is used to specify the transparent background-color.
  • initial: It is not used to set the background color. It sets the default value.
  • Inherit: It is used to inherit the background-color from its parent.

Let's see an illustration of this property.

Example

Test it Now





Contact US

Email:[email protected]

CSS Background-color
10/30