Syntax

background: [color] [image] [position] / [size] [repeat] [attachment] [origin] [clip];

Sub-Properties

PropertyValuesDefault
background-colorany colour valuetransparent
background-imageurl(), gradient, nonenone
background-positiontop left center 50% 20px0% 0%
background-sizecover contain auto px %auto
background-repeatrepeat no-repeat repeat-x repeat-y round spacerepeat
background-attachmentscroll fixed localscroll
background-originborder-box padding-box content-boxpadding-box
background-clipborder-box padding-box content-box textborder-box

Common Examples

/* Solid colour */
background: #6366f1;
background-color: #6366f1;

/* Image, cover, centered */
background: url('hero.jpg') center / cover no-repeat;

/* Full shorthand */
background: #060b14 url('texture.png') center / 200px repeat fixed;

Gradient Backgrounds

/* Linear gradient */
background: linear-gradient(135deg, #6366f1, #8b5cf6);

/* Radial gradient */
background: radial-gradient(ellipse at center, #1a1a2e, #060b14);

/* Conic gradient */
background: conic-gradient(from 90deg, #6366f1, #ec4899, #6366f1);

/* Gradient with stop positions */
background: linear-gradient(to right, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);

Multiple Backgrounds

/* Layers are listed front to back, separated by commas */
background:
  url('overlay.png') center / cover no-repeat,
  linear-gradient(135deg, #6366f1, #8b5cf6);

/* Each layer can have its own position, size, repeat */
background:
  url('dots.svg') top left / 20px 20px repeat,
  url('gradient.jpg') center / cover no-repeat,
  #060b14;
💡 Tip: background-color can only be on the last layer (it has no position/size/repeat). All other layers use images or gradients.