Starlit Daily

📚 › CSS: style and layout

7. Backgrounds

background-color sets a plain colour. background-image uses a picture or a gradient, for example linear-gradient(...). background-size: cover fills the box, and background-position moves the picture.

A gradient needs no image file, so it loads quickly.

Show example

.hero {
  background: linear-gradient(135deg, #7c9cff, #ff6bb5);
  color: white;
}

✍️ Your turn

Give .hero a linear gradient from red to blue.

← Back to course