Dev Helpers

CSS / Colour and backgrounds

Apply transparency to the whole element

Dev Helpers · February 2, 2026

Opacity composites an element and its descendants together. Text inside a translucent panel will fade along with its background.

Worked example

<style>
  .demo {
    opacity: 0.55;
  }
</style>
<div class="demo">Apply transparency to the whole element</div>

Implementation notes

Lowering foreground opacity is a poor substitute for an appropriately chosen muted text colour. The effective contrast changes with whatever sits beneath the element.

Try it yourself

Place the same white text over an opaque child inside the faded parent.

Open the CSS example →

Editorial date February 2, 2026 · Published December 6, 2026

Related articles

Fluid width with a maximum

A fluid container needs a small-screen width and a large-screen maximum. Outer gutters should remain visible at both extremes.

Square aspect ratio

A square ratio reserves equal sides even before media loads. Fit rules decide whether rectangular content is cropped or letterboxed.