Skip to main content
D
CSS
CSS Backgrounds

CSS Backgrounds

CSS backgrounds add colors and images behind elements.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

CSS controls the background area of any HTML element. Developers set solid colors, attach background images, or create smooth gradients. The background properties handle how these images repeat and position.

Example

Example
1/* this sets a background */
2body {
3  background-color: black;
4  background-image: url('stars.png');
5  background-repeat: no-repeat;
6}

Key Points

  • The `background-color` property sets a solid color.
  • The `background-image` property links an image file.
  • The `background-repeat` property prevents tiling.
  • The `background-size` property scales the image.

Up Next

Continue your journey with the next topic.

Go to CSS Borders