/    /  CSS Background-color

CSS Background-color

 

Set the background color of an element. The background of an element covers the total size, including the padding, border, and excluding margin.

 

Syntax:

 

element { 
  background-color: color_name|transparent|initial|inherit; 
}

 

color_name: Using the color name, hexadecimal value, or rgb() value.

transparent: Used to specify the transparent background-color.

initial: It sets the default value.

Inherit: Inherit the background-color from its parent.

 

Example:

 

<!DOCTYPE html>
<html>
  <head>
    <title>background-color property</title>
    <style> 
      body {
        text-align:center;
        background-color: #ffb3e6;       
      }
     h1{
      color: #660033;
     }
    </style> 
  </head>
  <body> 
   <h1>Hello World.</h1>
    <h1>Welcome to the I2tutorials</h1> 
    </body> 
</html>

 

OUTPUT:

 

CSS Background-color