# Low-contrast text over photos and hero images

Source: https://easeweb.dev/learn/text-over-images
Topics: Colour and contrast > Text has enough contrast (WCAG 1.4.3)
The fix: Give the words a backing that holds over the brightest photo the slot can show: a panel of at least 60% black, a gradient that dark wherever the words sit, or the whole photo darkened the same way. Or move the words off the photo, onto a plain background under it.
Test with: contrast measurement, zoom, forced colors
References: https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html https://www.w3.org/WAI/WCAG22/Techniques/failures/F83 https://www.w3.org/WAI/WCAG22/Techniques/general/G18 https://www.tpgi.com/color-contrast-checker/ https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

## What happens

A homeware shop opens its home page with a slideshow of three photos: linen napkins folded by a window, a towel on a stone counter, a table laid with a linen runner. The photos are soft and bright on purpose, and each slide lays a white headline, a line of text and a white "Shop" button over the top left of its photo, the way Bootstrap's carousel sets its captions: white, with nothing behind them. In the design file the words sat over the linen, and they looked calm and light.

On the live page the photos are cropped to the width of the window, and the top left of each one is the brightest part of the room: the window and the pale wall. The headline fades into it, and the line under it, at 17 pixels, is barely there. Press Next slide and the second and third photos are just as bright. Some shops notice and put a dark panel behind the words, but at 30% black it hardly changes how white text looks on a bright photo.

## Why it fails

WCAG 1.4.3 asks for at least 4.5:1 for normal text, and 3:1 for large text: 24px and up, or 18.66px and up when bold. The headline is 32px bold, so it needs 3:1; the line under it is 17px and needs 4.5:1. Text over a photo is measured against what is really behind its letters, and a photo has no single colour, so the part that counts is the one that gives the least contrast. Failure F83 names this case: a background image that doesn't give the text enough contrast.

- Straight on the photo: behind the first slide's headline, the window reaches `#fcfbfc`, and white on it is 1.03:1. On the second slide, the wall behind the words is `#e8e1d6`, at 1.30:1.
- On a 30% black panel: on the first slide the panel comes out at `#a8a49a` at its lightest, and white on it is 2.49:1. Where a photo is pure white, 30% black is `#b3b3b3`, at 2.10:1.

Nothing in CSS keeps text readable on whatever is behind it. The browser draws the colour the stylesheet gives, over whichever photo an editor uploads, so the designer has to plan for the brightest photo the slot will ever get, not the one in the mock-up.

## Who is affected

A glossy phone screen outdoors washes out the light half of a photo further, so a hero that is hard to read on a laptop can vanish on a phone. Slideshows add to it: each slide has its own photo, and a slide that is easy to read tells nothing about the next.

## What automation and AI miss

Most checkers stop at the image. axe leaves text over a background image or a gradient as "needs review", because it can't tell what colour is behind each letter. EaseWeb's audit measures it: for text with an image, a gradient or a video under it, it scrolls the text into view, waits for it to stop moving or fading, hides the words, takes a screenshot of the text's box, and measures the text colour against those pixels, taking the worst colour that covers a real part of the area rather than one stray pixel. Text drawn in a see-through colour, or with opacity, becomes a lead for a person to measure. It measures what is on screen when it runs: a slide that is hidden at that moment, and any photo uploaded later, is never measured. It also hides text shadows along with the words, so text that relies on a shadow is reported, and a person decides. An AI tool asked to review a mock-up sees only the photo in it, never the ones editors will upload later.

## Before: white words straight on the photo

```html
<div class="slide">
  <img src="/images/linen-napkins.jpg" alt="">
  <div class="slide-text">
    <h2>Linen for the table</h2>
    <p>Napkins, runners and tea towels, washed soft.</p>
    <a href="/linen">Shop table linen</a>
  </div>
</div>
```

```css
.slide {
  display: grid;
}
.slide img,
.slide-text {
  grid-area: 1 / 1;
}
.slide img {
  width: 100%;
  height: 18rem;
  object-fit: cover;
}
.slide-text {
  z-index: 1;
  margin: 1.5rem;
  color: #fff;
}
.slide-text a {
  background: #fff;
  color: #1a1a1a;
}
```

- The white words have nothing behind them but the photo.
- Behind the headline the window reaches `#fcfbfc`: 1.03:1, where the 32px bold headline needs 3:1.
- The line under it is 1.03:1 too, where 17px text needs 4.5:1.
- The other two slides are as bright, and the words don't change to match them.

## Before: a see-through panel too thin to matter

```html
<div class="slide">
  <img src="/images/linen-napkins.jpg" alt="">
  <div class="slide-text">
    <h2>Linen for the table</h2>
    <p>Napkins, runners and tea towels, washed soft.</p>
    <a href="/linen">Shop table linen</a>
  </div>
</div>
```

```css
.slide {
  display: grid;
}
.slide img,
.slide-text {
  grid-area: 1 / 1;
}
.slide img {
  width: 100%;
  height: 18rem;
  object-fit: cover;
}
.slide-text {
  z-index: 1;
  margin: 1.5rem;
  padding: 1rem 1.25rem;
  color: #fff;
  background: rgb(0 0 0 / 0.3);
}
.slide-text a {
  background: #fff;
  color: #1a1a1a;
}
```

This one looks backed: a dark panel sits behind the words. It is too thin to do the job:

- On the first slide the panel comes out at `#a8a49a` at its lightest, and the white words on it are 2.49:1, where the line under the headline needs 4.5:1.
- Where a photo is pure white, 30% black is `#b3b3b3`, and the white words are 2.10:1, under even the headline's 3:1.

## After: a panel behind the words

```html
<div class="slide">
  <img src="/images/linen-napkins.jpg" alt="">
  <div class="slide-text">
    <h2>Linen for the table</h2>
    <p>Napkins, runners and tea towels, washed soft.</p>
    <a href="/linen">Shop table linen</a>
  </div>
</div>
```

```css
.slide {
  display: grid;
}
.slide img,
.slide-text {
  grid-area: 1 / 1;
}
.slide img {
  width: 100%;
  height: 18rem;
  object-fit: cover;
}
.slide-text {
  z-index: 1;
  margin: 1.5rem;
  padding: 1rem 1.25rem;
  color: #fff;
  /* White text: 5.74:1 even if the photo is pure white */
  background: rgb(0 0 0 / 0.6);
}
.slide-text a {
  background: #fff;
  color: #1a1a1a;
}
```

1. Give the words a panel of 60% black. Over the brightest a photo can be, pure white, the panel is `#666666`, and white text on it is 5.74:1, so both the headline and the line under it pass on any photo.
2. Pad the panel, so the words never touch its edge where the photo shows through.

This fixes both Befores and passes 1.4.3 on every slide, whatever photo an editor puts in. The rest of each photo stays as bright as it was.

## After: a gradient under the words

```html
<div class="slide">
  <img src="/images/linen-napkins.jpg" alt="">
  <div class="slide-text">
    <h2>Linen for the table</h2>
    <p>Napkins, runners and tea towels, washed soft.</p>
    <a href="/linen">Shop table linen</a>
  </div>
</div>
```

```css
.slide {
  display: grid;
}
.slide img,
.slide-text,
.slide::after {
  grid-area: 1 / 1;
}
.slide img {
  width: 100%;
  height: 18rem;
  object-fit: cover;
}
/* At least 60% black over the bottom half, fading out above it */
.slide::after {
  content: "";
  background: linear-gradient(to top, rgb(0 0 0 / 0.75), rgb(0 0 0 / 0.6) 50%, rgb(0 0 0 / 0));
}
.slide-text {
  z-index: 1;
  align-self: end;
  margin: 1.5rem;
  color: #fff;
}
.slide-text a {
  background: #fff;
  color: #1a1a1a;
}
```

1. Lay a gradient over the photo that is 60% black or more across its bottom half. Wherever the words sit on at least 60% black, white text keeps 5.74:1, even over a white part of the photo.
2. Set the words at the bottom of the slide, inside that darker half.
3. Let the gradient fade out towards the top, so the upper half of the photo stays bright.

This fixes both Befores and passes 1.4.3, but only while the words stay in the bottom half. At a phone's width, or zoomed in, the words wrap onto more lines and grow up into the faded part, so measure it at every width.

## After: a darker photo

```html
<div class="slide">
  <img src="/images/linen-napkins.jpg" alt="">
  <div class="slide-text">
    <h2>Linen for the table</h2>
    <p>Napkins, runners and tea towels, washed soft.</p>
    <a href="/linen">Shop table linen</a>
  </div>
</div>
```

```css
.slide {
  display: grid;
}
.slide img,
.slide-text,
.slide::after {
  grid-area: 1 / 1;
}
.slide img {
  width: 100%;
  height: 18rem;
  object-fit: cover;
}
/* The whole photo under 60% black */
.slide::after {
  content: "";
  background: rgb(0 0 0 / 0.6);
}
.slide-text {
  z-index: 1;
  margin: 1.5rem;
  color: #fff;
}
.slide-text a {
  background: #fff;
  color: #1a1a1a;
}
```

1. Lay 60% black over the whole photo. Every point of it is then `#666666` or darker, so white text is at least 5.74:1 anywhere, and the words can sit and wrap wherever the layout puts them.

This fixes both Befores and passes 1.4.3. It is the simplest of the four, and it dims the whole photo.

## After: the words off the photo

```html
<div class="slide">
  <img src="/images/linen-napkins.jpg" alt="">
  <div class="slide-text">
    <h2>Linen for the table</h2>
    <p>Napkins, runners and tea towels, washed soft.</p>
    <a href="/linen">Shop table linen</a>
  </div>
</div>
```

```css
.slide {
  display: grid;
}
.slide img {
  grid-area: 1 / 1;
  width: 100%;
  height: 18rem;
  object-fit: cover;
}
/* Under the photo, on the page's white */
.slide-text {
  grid-area: 2 / 1;
  margin: 1.25rem 1.25rem 0;
  color: #1a1a1a;
}
.slide-text a {
  background: #1a1a1a;
  color: #fff;
}
```

1. Move the words into a row of their own, under the photo, where the page's white is behind them.
2. Set them in the shop's ink, `#1a1a1a`, at 17.40:1 on white, and turn the button round: white words on the ink, also 17.40:1.

This fixes both Befores and passes 1.4.3, and the photo shows in full, with nothing over it. A new photo can't change the ratio, so it needs no measuring.

## Which option to use

Each of the four passes. The panel holds on any photo and leaves the rest of it bright, at the cost of a dark box over the picture. The gradient shows more of the photo, but holds only while the words stay low, so it needs measuring at every width. The darker photo is the simplest, and it suits a photo that sets a mood more than one that shows the product. Moving the words under the photo is the only option that never depends on the photo at all: choose it when the photos are what sells, or when editors will swap them without anyone measuring.

## Implementation decisions

Build the backing into the slide or banner component, so it doesn't depend on which photo an editor picks. A theme setting for "overlay opacity" that starts at 0, as the image banner and the slideshow in Shopify's Dawn theme do, leaves every merchant who turns off the box behind the text to find the problem alone. Give the setting a floor that passes instead, or drop it.

Design to the worst case, not the average. A panel picked against the photo's average colour passes in the mock-up and fails on the next photo. The safe value for white text is the backing over pure white, and for dark text, the backing over pure black: a panel of 85% white is `#d9d9d9` over black, where `#1a1a1a` text is 12.33:1.

Some backings change the look without changing the ratio:

- A blur behind the words (`backdrop-filter: blur()`) calms a busy photo, but leaves it just as light; count only the darkening in the ratio.
- A soft text shadow seldom darkens enough of what is right behind each letter. Understanding 1.4.3 treats a wide outline that fills in the letters' inner details as a halo, part of the background, and says nothing of shadows, so measure the colour right around each letter if you rely on one.
- An `opacity` on the text, or a see-through text colour, makes the words lighter than their token, so measure what is drawn.

The same holds for every slide, including slides that are hidden until a button or a timer shows them, and for a looping video behind a headline, where every frame counts. The slideshow's arrows and dots are covered in [carousels that keyboard and screen reader users can't use](/learn/carousels), and a slideshow that moves by itself in [tickers, carousels and animations that can't be paused](/learn/moving-content). In forced colors, Chromium draws a plain backplate behind text over images; check the hero there rather than assume.

## Verify the fix

1. On every slide, banner and card with text over a photo, use the Colour Contrast Analyser's eyedropper on the text, then on the brightest pixel behind the letters (the darkest, for dark text), and confirm 4.5:1, or 3:1 for large text.
2. Narrow the window to a phone's width, then zoom to 200%, and repeat the measurement wherever the words wrap or move over another part of the photo.
3. Put the brightest photo the slot may ever get in place of each one (a plain white image will do) and confirm the backing still holds.

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the photos, the slideshow's layout or the theme change.

## Limits

This is a starting pattern, not a guarantee for every application. The colour values are examples; measure your own backings over your real photos. Text that is part of the photo itself, such as a street sign, is incidental and not covered by 1.4.3; words drawn into an image file are covered in [images of text instead of real HTML text](/learn/images-of-text). Text in a brand colour, and text that fades on hover, are in [low-contrast text in brand colours and hover states](/learn/text-contrast), and the 7:1 of Level AAA in [grey body text under 7:1 contrast](/learn/enhanced-contrast). A contrast ratio is a minimum, not proof that text is comfortable to read over a photo: check the complete pages with people who rely on it.

---

Get this guide in your coding agent: MCP https://easeweb.dev/mcp (setup at https://easeweb.dev/services/developers)
