Background Color and Image
Apply background colors and images using background-color and background-image properties.
background-color
The background-color property sets a solid color behind an element. It accepts any CSS color value and is visible through transparent areas of background images.
body {
background-color: #f5f5f5;
}
.hero {
background-color: hsl(210, 60%, 20%);
}background-image
background-image sets one or more images as the element background. Images are layered above background-color.
.banner {
background-image: url("hero.jpg");
background-color: #333; /* fallback */
}All lessons in this course
- Color Values: Named, Hex, RGB, HSL
- Background Color and Image
- Gradients: Linear and Radial
- Opacity and RGBA Transparency