CKTIS / CSS
background-image — background images
background-image sets background images, including gradients. A comma-separated list creates layers; the first image is on top.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
background-image: <bg-image>#;
<bg-image> = <image> | nonebackground-image accepts images referenced by url(), gradients, or none. The # in the grammar means one or more values, separated by commas. Its initial value is none; the property is not inherited.
The first layer is on top, with background-color beneath all images. Both none and an image that fails to load retain a layer but draw nothing. Set a fallback color that keeps text readable.
Size, position, and repetition are controlled by background-size, background-position, and background-repeat, respectively. A later background shorthand can reset background-image. Do not convey important information solely through a background image.
In the example, the first gradient's opaque red half covers the blue layer; its transparent half reveals it. Gradients require no external files.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Background image layers</title>
<style>
.sample {
width: 240px;
height: 120px;
background-color: #ffffff;
background-image:
linear-gradient(to right, #ff0000 50%, transparent 50%),
linear-gradient(#0000ff, #0000ff);
}
</style>
<div class="sample"></div>
</html>Result
A 240 × 120 CSS-pixel rectangle: the left half is red (#ff0000), and the right half is blue (#0000ff).
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.