← Back to CSS
24

Shadows in CSS: box-shadow and text-shadow

Use shadows to create depth, hierarchy and readability without pushing the UI into muddy, overdesigned territory.

📘 Theory

box-shadow

Offset, blur, spread and color define the perceived depth of a box.

1

The common pattern is `box-shadow: offset-x offset-y blur spread color`. Horizontal and vertical offsets place the shadow, blur softens it, spread grows or shrinks it, and color defines the tone.

2

You can also combine several shadows in one declaration. That is often how modern interfaces create softer, more realistic elevation.

text-shadow

Text shadows are most useful when they support readability, not when they become a gimmick.

1

`text-shadow` follows a similar structure: horizontal offset, vertical offset, blur and color. It works especially well for headings on photographs or dark gradients.

2

For long body text, use it very carefully. Readability usually improves more through contrast and spacing than through decorative shadow effects.

🧪 Learn by doing

Example Interactive demo: box-shadow and text-shadow Adjust blur, spread and text-shadow strength to understand how each parameter changes the mood of the UI.
Example Card with shadow Tweak the `box-shadow` declaration and compare how subtle and heavy shadows change the component.

🧰 Resources

Test

Check your knowledge with a test about CSS.

Test for CSS

What is this?

I'm Cristian Eslava and I sometimes build websites so both you and I can learn and experiment. culTest

I made this in February 2026 to make learning easier for my students. The idea is to learn web development by practicing and to keep expanding the project with new topics, tests and challenges.

It draws inspiration from MDN, W3Schools, CodePen, Manz and many other web development references. I wanted to combine useful theory, runnable examples, challenges and the testing system I had already built for culTest. culTest

If you liked it, if you didn't, or if you want to get in touch, write to me at cristianeslava@gmail.com