Sub topic 11
Scrims, gradients and overlays for readable text
This chapter assumes you know how to place text over an image (the previous chapter) and how to measure contrast. Here you will learn how to add a layer between text and photo so the text stays readable while the image stays visible.
What a scrim does
A scrim is a semi-transparent layer placed between the image and the text. It lowers the brightness or variation of the pixels behind the type. Contrast improves because the background gets more uniform, and the photo is not replaced.
There are three common treatments:
| Treatment | What it covers | Best for | Main risk |
|---|---|---|---|
| Full overlay | The whole image with one flat tint | Backgrounds where mood matters more than detail | Image looks flat and muddy |
| Gradient scrim | One edge, fading to clear | Text anchored at the top or bottom | A visible band if the fade is too abrupt |
| Local panel or blur | Only the area behind the text | Busy images with text in the middle | Looks like a box stuck on the photo |
Choosing a treatment
Start with the least intrusive option. A gradient on one edge keeps most of the photo untouched, so it is usually the first thing to try.
A gradient scrim in practice
The CSS below fades black in from the bottom of the background photo. White text anchored at the bottom stays readable without covering the whole image.
.hero {
position: relative;
min-height: 24rem;
display: flex;
flex-direction: column;
justify-content: flex-end;
padding: 2rem;
color: #fff;
background:
linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0) 60%),
url("coast.jpg") center / cover no-repeat;
}Three details matter:
- The gradient is listed first in
background, so it paints on top of the photo. - The gradient ends at
rgba(0, 0, 0, 0), which is transparent black. Fading to the keywordtransparentcan create a grayish midpoint in some browsers. - The stop at
60%means the scrim covers the lower 60% of the box. The text sits in the darkest part.
In a design tool, the same result is a rectangle filled with a black-to-transparent linear gradient, placed above the photo and below the text layer.
Tuning the scrim
- Place the text and check its contrast against the darkest and lightest areas behind it. The lightest area decides whether the text passes.
- Raise the scrim opacity in steps of about 10 percent until the worst spot passes.
- Stop as soon as it passes. More opacity only costs image quality.
- Move the gradient's start point so the fade ends before the focal point of the image.
Common errors
- A hard edge where the gradient ends, which shows as a visible stripe. Add a longer, softer fade.
- A uniform dark overlay on the whole image, which dulls the colors the photo was chosen for.
- Checking contrast on the unchanged photo instead of on the final composite.
Exercise
Your headline is white and sits at the bottom of a bright beach photo, and the bright sand behind it fails the contrast check. Which treatment do you try first, and how do you decide how strong to make it?
Show answer
Try a bottom-anchored gradient scrim, because the text sits at an edge. Increase its opacity in small steps until the lightest area behind the text passes the contrast check, then stop. Keep the fade ending before the photo's focal point.