Dappled light — the soft, shifting patches of sun that slip through foliage — has long been a device painters use for a hypnotic, gentle mood. The same effect can be produced in a layout with plain CSS, applied over photos or illustrations to give otherwise flat walls of content some life.

What makes dappled light look like dappled light

The effect is built from large circular or elliptical spots of light, intercepted by shadows from leaves and branches. Edges are sometimes crisp, but more often blurred: light passes through many loosely defined gaps, which diffuse and distort it, and the shadows are cast from farther away than a sharp, close-range silhouette would be.

An oil painting of a tall rectangular orange building with six windows, two by two, and a faint full-width fence in front of it. There is a similar building off in the distance. A tall birch tree is in the foreground with light green and yellow leaves, casting the dappled light effect that is being covered in this article. The shadows cover the green grass between the tree and building, and they extend to the building.
Bedford Dwellings by Ron Donoughe (2013)

The wall below shows the difference between plain white and the same surface under dappled light:

A side-by-side comparison of the same white brick surface, the left showing the CSS dappled light effect compared to no shadows.
The effect creates splashes of light and shadow.

Building the surface and the light shapes

Text characters supply the shapes: letters, special characters, emojis, anything elliptical or oblong. Pick characters that feel varied — for this example, 🍃, 🍂 and \, chosen for being elliptical, oblong and slanted, adding a little chaos to an otherwise serene scene.

The characters sit in paragraphs inside a .backdrop parent element:

<div class="backdrop">
  <p class="shapes">🍃</p>
  <p class="shapes">🍂</p>
  <p class="shapes">\</p>
</div>

The parent acts as the surface that receives the light and shadow. It gets a background image for texture, explicit width and height, and hidden overflow so shadows can extend past the surface without becoming visible. CSS grid centers the casting elements on that surface:

.backdrop {
  background: center / cover no-repeat url('image.jpeg');
  width: 400px; height: 240px;
  overflow: hidden;
  display: grid;
}
.backdrop > * {
  grid-area: 1/1;
}

Exact alignment of the shapes isn't necessary — overlapping is what produces the effect, and different positioning values will yield different dappled patterns.

Core styling of the light shapes

Four properties do the heavy lifting: transparent text color, a black semi-transparent background set through the alpha channel in rgba(), a blurry white text-shadow at a large font-size, and a mix-blend-mode to smooth the result.

.shapes {
  color:  transparent;
  background-color: rgba(0, 0, 0, 0.3); // Use alpha transparency
  text-shadow: 0 0 40px #fff; // Blurry white shadow
  font: bolder 320pt/320pt monospace;
  mix-blend-mode: multiply;
}

mix-blend-mode controls how an element's colors blend with its container's content. With multiply, the backdrop shows through the element's light colors while dark colors stay dark, which reads as more natural light.

Brightness, blending alternatives and fallbacks

To lift the backdrop's background-image, this example adds filter: brightness(1.6). A different route is background-blend-mode: blend an element's backgrounds with each other and supply the emojis as background images rather than separate elements. That variant also swaps in a different emoji and uses floralwhite instead of pure white for a less intense light.

<svg xmlns='http://www.w3.org/2000/svg'> 
  <foreignObject width='400px' height='240px'> 
    <div xmlns='http://www.w3.org/1999/xhtml' style=
      'font: bolder 720pt/220pt monospace;
       color: transparent;
       text-shadow: 0 0 40px floralwhite;
       background: rgba(0, 0, 0, 0.3);'
    >
      🌾
    </div> 
  </foreignObject> 
</svg>

For custom images as the light shapes, blur the borders so the light stays soft — the blur() filter works well for this. A CSS @supports block adjusts the shadow blur value for certain browsers as a fallback.

Returning to the first example, a few additions complete it:

<div class="backdrop">
  <p class="shapes">🍃</p>
  <p class="shapes">🍂</p>
  <p class="shapes">\</p>
</div>

<p class="content">
  <img width="70px" style="float: left; margin-right: 10px;" src="image.jpeg" alt="">
  Top ten tourists spots for the summer vacation <br><br><i style="font-weight: normal;">Here are the most popular places...</i>
</p>

.backdrop and .shapes keep their earlier styles. The .content layer, which also sits above the backdrop, receives isolation: isolate to create a new stacking context, keeping it out of the blending as a refining touch.

A slow shift of the light

A @keyframes animation applied to .backdrop on :hover gives the scene subtle motion:

.backdrop:hover > .shapes:nth-of-type(1){
  animation: 2s ease-in-out infinite alternate move;
}
.backdrop:hover > .shapes:nth-of-type(2):hover{
  animation: 4s ease-in-out infinite alternate move-1;
}

@keyframes move {
  from {
    text-indent: -20px;
  }
  to {
    text-indent: 20px;
  }
}
@keyframes move-1 {
  from {
    text-indent: -60px;
  }
  to {
    text-indent: 40px;
  }
}

Animating text-indent on the emojis produces a movement just faint enough to suggest clouds passing overhead and shifting the direction of the light.

The recipe in brief

Color is what carries the effect: a light-colored, heavily blurred text-shadow provides the light, and a semi-transparent background-color defines the shadow spots. The backdrop then needs a realistic texture with enough contrast for the dappled light to register — at which point a small handful of CSS and a few emoji are enough to reproduce a partly cloudy day beneath trees.