The CSS background properties are used to define the background effects for elements.
In these chapters, you will learn about the following CSS background properties:
The background-color
property specifies the background color of an element.
.card {
background-color: lightblue;
}
The background-image
property specifies an image to use as the background of an element.
By default, the image is repeated so it covers the entire element.
.card {
background-image: url("car.jpg");
}
By default, the background-image
property repeats an image both horizontally and vertically.
.card {
background-image: url("car.jpg");
background-repeat: repeat-x;
}
<aside>
📌 Tip: To repeat an image vertically, set background-repeat: repeat-y;
and If you don't want the image to repeat, use background-repeat: no-repeat;
</aside>