CSS Backgrounds
Background Properties
CSS provides several properties to style element backgrounds:
background-color
Example
div {
background-color: #4b3190;
}
background-image
Example
div {
background-image: url('image.jpg');
}
background-repeat
Example
div {
background-image: url('pattern.png');
background-repeat: no-repeat;
}
background-position
Example
div {
background-image: url('image.jpg');
background-position: center top;
}
background-size
Example
div {
background-image: url('image.jpg');
background-size: cover;
}
Shorthand Property
You can use the background shorthand property:
Example
div {
background: #4b3190 url('image.jpg') no-repeat center;
}