CSS Backgrounds
The CSS background properties are used to add background effects for elements.
CSS background properties let you style the background of any element with colors, images, gradients, and control their position and repeat behaviour.
Try It — All Background Types
Preview
Background Properties Reference
| Property | What it does | Example |
|---|---|---|
background-color | Solid fill color | background-color: #f0f0f0 |
background-image | Image or gradient | background-image: url(...) |
background-repeat | Controls image repeat | no-repeat, repeat-x, repeat-y |
background-position | Where to place background | center, top right |
background-size | Scale the background | cover, contain |
Tip: Use
background: linear-gradient(to right, #color1, #color2)to create smooth gradient backgrounds without any images!