CSS Background Image Generator

A hero photo needs a dark wash over it before the headline reads. Stack the photo, the gradient and any pattern here, drag the order around, then take the rule that CSS actually wants: one comma separated list per property.

340px

Layers

Base colourPaints behind the stack and shows through anything transparent. It is also what a visitor sees while the images are still downloading.
Generated CSS
0Layers drawn
0Network requests
0Declarations
0 BOutput size
Start from

The first layer in the list paints on top

This trips up almost everyone the first time. In background-image, the first value in the comma separated list sits nearest the visitor and every later value stacks behind it. The base colour sits behind all of them. The panel above labels the first card Top and the last one Base so the order on screen matches the order in the rule.

Gradient firstreadable
background-image:linear-gradient(180deg,transparent, rgba(11,17,32,0.8)),url("hero.avif");
Photo firstgradient hidden
background-image:url("hero.avif"),linear-gradient(180deg,transparent, rgba(11,17,32,0.8));

Both rules are valid and both load the same photo. The one on the right paints an opaque photo across the whole box, so the gradient behind it never shows a pixel. When a wash you wrote refuses to appear, the order is the first thing to check.

Why the dark wash exists

White text on a photograph reads fine over the sky and vanishes over the pale wall in the corner. Contrast is measured against the pixels behind each letter, and a photo gives you no control over those pixels. A gradient layer between the photo and the text gives back that control: the bottom of the box gets a known colour, so the headline sits at a contrast ratio you measured once instead of one that shifts when the photo is swapped.

Three habits keep this honest:

  1. Fade to a colour rather than to black. A wash in the same family as the photo looks deliberate, while flat black over a warm image reads as a mistake.
  2. Start the gradient at zero alpha and end near 80 percent. A wash at full opacity across the whole box means you did not need the photo at all.
  3. Test the headline over the busiest corner, not the calm one. Turn on Sample text above, drag the box narrow, and watch what happens when the photo is cropped by cover on a phone.

Blend modes do a different job. multiply pushes a colour into the shadows of the photo, screen lifts the highlights, and luminosity strips a photo down to greyscale while a colour layer below tints it. They blend against the layer beneath, so a blend mode on a lone layer only ever interacts with the base colour.

Every background property takes a list

Once there are two images, the other background properties become lists too, matched by position: the first background-size belongs to the first image, the second to the second. A short list repeats itself to cover the images, which is where surprising results usually come from.

PropertyWhat it does per layerWorth knowing
background-sizecover fills the box and crops, contain fits the whole image and leaves gaps, two values set width and height directly.Gradients respond to size the same as photos. A radial gradient at 70% 70% becomes a soft spotlight instead of a wash.
background-positionAnchors the image inside the painting area. Percentages align the same point of the image with that point of the box.With cover, position decides what survives the crop. Faces near an edge want top rather than center.
background-repeatTiles the image. space distributes whole tiles with gaps, round stretches them so a whole number fits.Only worth setting on a tile whose edges line up. A photo set to repeat shows its seams down the middle of the box.
background-attachmentscroll moves with the box, fixed pins the image to the viewport, local follows the content of a scrolling box.fixed repaints on every scroll frame and iOS Safari ignores it inside scrolling containers. That is the whole story behind broken parallax on iPhones.
background-blend-modeBlends each layer with the layers below it inside the same element.Different from mix-blend-mode, which blends the whole element with the page behind it.
background-origin / clipDecides whether painting starts at the border, the padding edge or the content box.Not generated here. Add them by hand when a dashed border needs to sit clear of the image.

The shorthand packs one layer per comma with the syntax image position/size repeat attachment. One rule to remember: background-color is allowed only in the final layer, and the shorthand resets every property it leaves out. Writing background: url(a.png) after a background-repeat line silently throws that repeat away. The longhand tab avoids the whole problem, which is why it is the default here.

When a background image is the wrong tool

A CSS background is decoration. The browser gives it no alternative text, screen readers skip it, and it stays invisible to image search. Anything a reader needs in order to follow the page belongs in an <img> tag with an alt attribute: product photos, charts, portraits, screenshots in a tutorial.

Backgrounds win when the artwork is decorative, when it has to sit behind live text, when it tiles, or when it is generated by gradients and costs no request at all. The dot grid and stripe presets above are the second case: pure CSS, no download, and they scale to any screen density.

Formats, density and the parts this page skips

Everything here runs in your browser and nothing you paste is uploaded. Four things the output deliberately leaves out, each because guessing at them tends to produce code people delete later:

The photo preset uses an inline SVG placeholder, not a stock image. It keeps the preview working offline and keeps the tool free of a third party host. Swap the URL for your own asset before shipping. If the preview stays blank after you paste a real URL, the file is almost always blocked by hotlink protection or by a CORS rule on the origin, not broken CSS.

Questions that come up while stacking layers

The things people ask once a real photo is sitting in the preview.

Which layer sits on top?

The first one in the comma separated list, and the first card in the panel above. Later values stack behind it and the base colour paints last of all. Put your gradient wash before the photo, never after it, or the opaque photo covers the wash completely.

My gradient overlay is not showing. What went wrong?

Three usual causes. The photo is listed first and hides it. Both gradient stops are fully transparent, which paints nothing. Or the gradient layer inherited background-size: cover with a position that pushed it outside the box. Toggle layers off one at a time with the circle button to find which one is at fault.

Should I use the longhand or the shorthand?

Longhand for anything a team maintains. The shorthand resets every background property it omits, so a later shorthand quietly wipes a background-repeat set above it, and a stack of three layers turns into one long line that nobody wants to review. The shorthand tab is there for a quick paste into a prototype.

Why does background-attachment: fixed break on iPhone?

iOS Safari treats a fixed background inside a scrolling container as scroll instead, which is why parallax built this way works on desktop and sits still on a phone. It also forces a repaint on every scroll frame. A position: sticky element or a small scroll driven animation is the steadier route.

Can I put my own gradient value in an image layer?

Not directly. Image layers take a URL, gradient layers take two colours. For a multi stop gradient, generate it on the gradient tool and paste the whole value into your stylesheet in place of one of the url() entries. The size, position and repeat you set here still apply to it.

Do the CSS gradients cost anything to load?

No request, since the browser paints them from the rule itself. They cost paint time instead, which shows up when a large gradient repaints on every scroll or resize. The stripe and dot presets stay cheap because they tile a small area.

How do I serve a different crop on mobile?

Build the phone layout at 320 wide, copy the declarations, then rebuild for desktop and copy again. Wrap each set in its own media query. If the image carries meaning rather than decoration, a picture element with two source tags is the better answer and gives you alt text as well.

Is anything uploaded when I paste an image URL?

No. The URL goes into a style property in your own tab, so your browser fetches the image the same way any page would. Nothing is sent to this site and nothing is stored between visits.