A card can use black text on a white background and still deliver poor text contrast. Add opacity: 0.5 to the card and the browser fades its contents too. Setting opacity: 1 on the text does not bring the black back.

This is easy to miss when a design calls for a translucent panel: the property that fades the whole component looks like a convenient shortcut for making its background transparent. The two operations have different effects on readability.

The parent is faded after its children are drawn

The CSS Color specification describes opacity as a postprocessing operation. The element and its descendants are rendered together, then that result is blended into the page beneath it.

Opacity is not inherited, but that does not protect descendants from their ancestor’s final compositing step. A child at full opacity is still part of the group being faded.

Here is a small example on a white page:

<div class="card">
  <p class="card-text">
    Your export is ready.
  </p>
</div>
body { background: #fff; }
.card {
  background: #fff;
  color: #000;
  opacity: 0.5;
}
.card-text { opacity: 1; }

The card’s white background remains white against the white page. Its black text blends towards white, becoming approximately mid-gray. Checking only #000000 against #ffffff gives 21:1, but that is not the color pair this faded card presents.

For ordinary sRGB compositing over an opaque background, each resulting color channel follows the source-over calculation:

result =
  foreground × alpha +
  background × (1 − alpha)

Half-opacity black over white gives 0 × 0.5 + 255 × 0.5 = 127.5 per channel. Rounded to an eight-bit color, that is #808080, whose contrast against white is 3.95:1. The continuous-value calculation is about 3.98:1; either result falls below the 4.5:1 minimum for ordinary text in WCAG 2.2’s Contrast (Minimum) criterion.

Make the background translucent, not the component

If the intended effect is a see-through panel with solid text, remove the card-level fade and put the alpha value in its background color:

.card {
  background: rgb(255 255 255 / 50%);
  color: #000;
  opacity: 1;
}

On the white page, this keeps black text on white at 21:1. The white backdrop deliberately makes the difference easy to isolate: only the text changed in the faded version. On a colored page, the translucent background will also take on some of that color, so check the resulting background rather than assuming it is still white.

If the text remains faded after this change, inspect the card’s ancestors. An enclosing section with reduced opacity still composites the whole subtree; adding more opacity: 1 declarations below it cannot undo that step. Move transparency to the background of the element that actually needs it.

Reproduce the failure before choosing the fix

In ToolSprinkle’s contrast checker, choose black text, a white background and 50% foreground opacity, then run the tool. It reports 3.95:1 and AA normal text: Fail. Set opacity to 100% and run again to get 21.00:1. Here, foreground opacity reproduces the faded text against the unchanged white surface; it is not a simulation of an arbitrary layered card.

For the actual page, inspect both the text and the surface behind it, including ancestor opacity. If the panel sits over a photograph or gradient, check the backgrounds beneath the text across the layouts where it appears. When those backgrounds vary too much, an opaque text surface is often the simpler design choice.

Use the unrounded contrast value for the pass/fail decision: W3C explicitly notes that 4.499:1 does not pass a 4.5:1 threshold. Its guidance also says to evaluate the intended foreground and background colors rather than sampling anti-aliased letter edges from a screenshot. Keep enough contrast margin that a thin typeface does not have to rely on a barely passing pair.

← All articles