Categories
Web development

CSS background-color Property

CSS background-color Property

The CSS background-color property settles the background colour of an element.

Syntax:

background-color: color|transparent;

color – defines the background color (in HEX, RGB, RGBA, HSL values).

transparent (default) – defines that the background color should be transparent.

Example:

<!DOCTYPE html>
<html>
<head>
<style>

.square {
   position: relative;
   width: 100px;
   height: 100px;
   background-color: #2a9d8f;
    }

</style>
</head>
<body>

<div class="square"></div>

</body>
</html>

Output:


Enjoy coding!

Read also:

CSS border-top Property

CSS border-image Property