CSS background-color property
CSS

CSS background-color property

Mishel Shaji
Mishel Shaji

CSS background-color property is used to set the background color of an element. You can specify the color as keyword value, Hexadecimal value, RGB value, HSL value etc.

Look at my background color

Syntax

background-color: value;

Example

<!DOCTYPE html>
<html>
<head>
    <title>CSS text decoration color</title>
    <style>
        .ms-p1{
            background-color: yellow;
        }
        .ms-p2{
            background-color: #CC7A00;
        }
        .ms-p3{
            background-color: rgb(245, 255, 191);
        }
        .ms-p4{
            background-color: hsl(86, 32%, 61%);
        }
    </style>
</head>
<body>
    <p class="ms-p1">Background color is specified as color name</p>
    <p class="ms-p2">Background color is specified as hex value</p>
    <p class="ms-p3">Background color is specified as RGB value</p>
    <p class="ms-p4">Background color is specified as HSL value</p>
</body>
</html>

Output

Background color is specified as color name

Background color is specified as RGB value

Background color is specified as hsl value

Background color is specified as color name

Learn about the shorthand CSS background property.