CSS background Property Reference

The CSS background shorthand sets multiple background properties in one declaration.

CSS background Property Reference

The CSS background shorthand sets multiple background properties in one declaration.

Updated 2026-08-07

Shorthand syntax

Use background to set an image, position, size, repeat behavior, attachment, origin, clipping area, and color. Omitted components reset to their initial values, so a shorthand declaration can overwrite earlier background-* declarations.

Write position before the optional slash and size after it. A background color may appear only in the final layer.

CSS .hero { background: #eef url("hero.svg") center / cover no-repeat; }

Multiple layers

Comma-separated layers are painted from first to last, so the first image is visually closest to the user. Only the last layer may include a color fallback.

CSS .banner { background: linear-gradient(rgb(0 0 0 / 0.35), rgb(0 0 0 / 0.35)), url("mountains.jpg") center / cover no-repeat, #263238; }

Background longhands

LonghandPurpose
background-colorPaints the fallback color.
background-imageSets images or gradients.
background-positionPositions each image.
background-sizeSizes each image.
background-repeatControls tiling.
background-attachmentControls scrolling behavior.
background-originSets the positioning box.
background-clipLimits the painted area.

Accessibility

Description

The CSS background shorthand sets multiple background properties in one declaration.

References

  1. CSS Backgrounds and Borders Module Level 3
  2. MDN: background

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies