
CSS shadows can improve contrast or show depth. Text and box shadows have different syntax even though both use offsets, optional blur, and a color.
1. Text shadows
The first two lengths move the shadow horizontally and vertically. A third length can blur it. Text shadows have neither a spread length nor an inset option.
h1 { text-shadow: 1px 2px 3px rgb(0 0 0 / 35%); }2. Box shadows
A box shadow can add a spread radius after blur. Negative spread contracts the shadow. The optional inset keyword puts the effect inside the box.
.card { box-shadow: 0 4px 12px 0 rgb(0 0 0 / 18%); }
.field { box-shadow: inset 0 1px 3px rgb(0 0 0 / 20%); }3. Multiple shadows
Separate each shadow with a comma. Keep text legible without the effect and use a contrasting border or background if the shadow is difficult to see.
.panel { box-shadow: 0 2px 4px #0002, 0 12px 24px #0002; }4. Generators and practice
A visual generator can help you explore combinations. Copy the declaration only after checking contrast, and change one length at a time to see what it does in the example.