White headline text over a bright photograph is a gamble. Part of the image is dark enough, part of it is sky, and somewhere over the clouds the words vanish. The standard fix is a scrim: a gradient laid over one edge of the photo that darkens it enough for the text on that edge to stay readable, while the rest of the picture shows through.
This guide explains how to build that scrim, and starts with an honesty point worth stating up front. The free CSS Gradient Generator on Ovatly cannot produce the layered effect on its own. What it can do is settle the two design decisions, the color pair and the angle, before you rebuild the gradient with transparency in your own stylesheet.
Contents
- Quick answer
- Why headlines on photos fail without a scrim
- What the generator can and cannot do here
- The real technique: stacked backgrounds
- Step by step: prototype, then rebuild with alpha
- Worked example: from a blue pair to a bottom scrim
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
Layering a gradient over a photo is stylesheet work, not generator output. The CSS Gradient Generator emits one background declaration whose stops are solid hex colors, so it cannot fade to transparent and it does not place anything over an image. In your CSS, backgrounds stack: list a gradient layer first and the photo second in one background shorthand, and the gradient paints on top. The scrim itself needs alpha colors, written as rgba(), so it can run from fully transparent to mostly opaque. Use the generator to prototype the colors and the angle, then rebuild the same gradient with alpha values by hand.
Why headlines on photos fail without a scrim
A photograph is not a background color. Its brightness changes from corner to corner: a dark tree line at the bottom, pale sky at the top, a bright window in the middle. Any single text color will match some of those areas and clash with others. White text that reads over the tree line disappears over the sky.
A scrim fixes this by darkening the image only where the text sits. A gradient that is transparent across most of the photo and darkens toward the bottom edge gives the headline a dark patch to stand on, without flattening the whole picture under a solid overlay. The key word is transparent. A scrim is a fade, and a fade is exactly what a solid hex gradient is not.
What the generator can and cannot do here
Be clear about the division of labor. The generator builds linear, radial and conic gradients from up to six stops and hands you a single CSS background declaration. Its stops are solid hex colors, always fully opaque. It has no photo input, no layering control, and no transparency.
What it is good for is the decision you have to make anyway: which colors, and at what angle. Its preview is a live CSS rendering, so you can try color pairs and spin the angle from 90deg to 180deg and watch the blend change direction. That prototype is much faster than editing alpha values blind in a stylesheet and refreshing the page after every guess.
The real technique: stacked backgrounds
CSS supports multiple background layers. One background shorthand can list several layers separated by commas, and the layer written first paints on top. So a headline scrim is written like this, in your own stylesheet:
.hero {
background:
linear-gradient(180deg, rgba(37, 99, 235, 0) 40%, rgba(37, 99, 235, 0.85) 100%),
url("hero.jpg") center / cover;
}
Read it top to bottom. The gradient layer comes first, so it sits above the photo. It starts fully transparent, stays transparent until 40% of the way down, then deepens to 85% opaque at the bottom edge, which is where the headline goes. The photo underneath shows through wherever the gradient is clear. None of this comes out of the generator: the stacking, the image and the alpha values are all yours.
Step by step: prototype, then rebuild with alpha
- Open the CSS Gradient Generator and choose the linear type.
- Set the angle for where your text sits. For a headline at the bottom, 180deg runs top to bottom, so the second stop color lands at the bottom edge.
- Pick the pair: a lighter first stop and the deeper color you want behind the text as the final stop. Judge the pair in the preview at roughly your hero area's proportions.
- Copy the declaration the generator produces. This is your reference for the colors and angle, not the finished scrim.
- In your stylesheet, rewrite that gradient with alpha: convert the deep stop color to
rgba()at high opacity, set the starting stop to the same hue at zero opacity, and hold transparency until partway down. - Stack the layers in one
backgroundshorthand on the hero element, gradient first, photo second, and check the real page with the real headline in place.
Worked example: from a blue pair to a bottom scrim
Suppose the prototype settles on the blue pair at 180deg. The copied declaration reads:
background: linear-gradient(180deg, #0ea5e9 0%, #2563eb 100%);
That is a solid blend from sky blue to deep blue, useful as a reference and useless as a scrim, because at full opacity it hides the photo. The rebuild keeps the geometry and changes the paint. The deep end, #2563eb, is rgb(37, 99, 235). Written with alpha, the scrim holds that hue at zero opacity through the top 40%, where no text sits, and rises to 0.85 at the bottom edge. The result is the .hero rule shown above: the same downward direction, the same deep blue doing the darkening, and a photo that still shows through everywhere the headline is not.
Limitations and honest tradeoffs
The generator contributes a prototype and nothing more. It cannot emit alpha, cannot stack layers, and cannot show you the gradient over your actual photo, so the final judgement happens on your real page. A scrim is also a compromise by nature: darken too little and the text still struggles, darken too much and you have buried the photograph you chose. And a scrim only helps where it is. Move the headline to the top and the bottom scrim does nothing for it; the gradient has to follow the text.
Common mistakes
- Pasting the generator's declaration straight over a photo. A solid hex gradient at full opacity covers the image completely. If the photo has vanished, the alpha rebuild was skipped.
- Listing the photo layer first. Layers paint in order, first on top. Put the image first and it covers the gradient, and the scrim stops existing.
- Darkening the wrong edge. At 180deg the final stop sits at the bottom. If your headline is at the top, flip the angle to 0deg so the deep end lands where the words are.
- Making the whole gradient semi-transparent. A scrim needs a transparent region and a strong region. A uniform 50% wash dulls the photo and still leaves bright spots behind the text.
- Skipping the real-page check. The prototype preview is a flat rendering, not your photo. Readability can only be judged with the real image and the real headline together.
FAQs
Can the CSS Gradient Generator layer a gradient over my photo? No. It emits a single background declaration whose stops are solid hex colors. It never touches your photo and cannot produce a transparent fade. Layering the gradient over an image happens in your stylesheet, where CSS backgrounds stack.
Why does a headline scrim need transparent colors?
A solid gradient would cover the photo completely. The scrim works because it runs from transparent, where the image should show through, to mostly opaque behind the text. That requires alpha colors such as rgba(), which the generator's hex-only output does not provide.
Which background layer paints on top? The first one listed. In a background shorthand with several comma-separated layers, the layer written first is painted above the others, so the gradient goes before the image URL.
What angle should a headline scrim use? Most headlines sit at the bottom of a hero image, so an angle of 180deg, which runs top to bottom, puts the final stop color at the bottom edge where the text is. Prototype the angle in the generator, then keep it when you rebuild the gradient with alpha.
Is anything uploaded when I use the generator? No. The generator runs fully locally in your browser, and it never receives your photo at all. You only bring it colors and an angle, and you copy out a CSS declaration.
Conclusion
A readable headline over a photo comes from a stacked background in your stylesheet: a transparent-to-opaque gradient layered above the image. The CSS Gradient Generator cannot output that effect. Its honest role is the fast prototype: settle the color pair and the angle in a live preview, then rebuild the winner with alpha where the real technique lives. For the opposite problem, gradients that snap instead of fade, see our comparison of hard stop vs blended gradients. For more guides in this series, see our Website and Webmaster Tools guides.
References
- MDN Web Docs, on the background shorthand and stacking multiple background layers: https://developer.mozilla.org/en-US/docs/Web/CSS/background
- MDN Web Docs, on linear gradients and color stops: https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient