CHAPTER 50

CSS Shadows

Learn how box-shadow and text-shadow create depth and visual hierarchy in web designs.

01. What is CSS Shadows?

box-shadow adds a shadow around an element.
text-shadow adds a shadow behind text.
Shadows can create depth, elevation and focus.
Multiple shadows can be combined.

02. Syntax

box-shadow: x-offset y-offset blur spread color; text-shadow: x-offset y-offset blur color;

03. Example

CSS / HTML Example AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>

<style>

.card {

    width: 300px;

    padding: 30px;

    background: white;

    border-radius: 18px;

    box-shadow:
        0 20px 40px
        rgba(0,0,0,.15);

}

h1 {

    color: #2563eb;

    text-shadow:
        2px 3px 8px
        rgba(0,0,0,.25);

}

</style>

</head>

<body>

<div class="card">

    <h1>
        AIFA
    </h1>

    <p>
        Premium CSS Card
    </p>

</div>

</body>
</html>

04. Important Points

✓ box-shadow creates depth around boxes.
✓ text-shadow creates depth behind text.
✓ Blur radius controls how soft the shadow appears.
✓ Subtle shadows often create cleaner interfaces.

05. Common Mistakes

⚠ Using extremely dark shadows everywhere.
⚠ Creating excessive blur.
⚠ Using too many shadows that make the interface visually heavy.

06. Real World Use

Shadows are commonly used in cards, buttons, navigation bars, modals, dashboards and premium UI designs.

Ready to Practice? 🚀

Open the AIFA CSS Editor and practice this chapter live.

Try It Yourself →
Practice Exercise

Create a Premium Card

Create a white card with rounded corners and a soft box-shadow. Add a heading with a subtle text-shadow.