This can be done using the background
, background-color
, background-image
, background-repeat
, background-position
, and background-size
properties.
/* Examples */ .element { background-color: lightblue; /* Changes background color */ } .element { background-image: url('image.jpg'); /* Sets an image as the background */ background-repeat: no-repeat; /* The image will not repeat */ background-position: center; /* Centers the image in the element */ background-size: cover; /* Scales the image to cover the element */ }