CSS Tutorial

CSS Shadow Effects: box-shadow, Multiple Shadows And Neumorphism Explained (2026-27)

By Pramod Behera  ·  Updated: June 2026  ·  13 min read
✅ In this CSS Tutorial - CSS Shadow Effects: Complete Guide to box-shadow, Glow, Elevation & Neumorphism

Today we are discuss topic CSS Shadow Effects. A flat rectangle on a flat background can look lifeless — a touch of box-shadow is often all it takes to give a card, button, or panel a sense of depth and physical presence. In this complete guide you will master the four box-shadow length values — offset-x, offset-y, blur-radius, and spread-radius — shadow color and transparency, the inset keyword for recessed effects, layering multiple shadows with commas for realistic elevation, building soft glow effects, the popular neumorphism technique, and pairing box-shadow with border-radius for polished rounded cards. Includes live code panels, an interactive shadow builder, comparison tables, common mistakes, a quiz, and FAQ — everything you need to add convincing, professional depth to your UI. This tutorial or document breaks down the process step by step, using simple language and real-world examples to help you master the skill.

📋 Table of Contents

  1. What Is CSS box-shadow?
  2. offset-x & offset-y - Positioning the Shadow
  3. blur-radius - Softening the Edges
  4. spread-radius - Growing or Shrinking the Shadow
  5. Shadow Color & Transparency
  6. The inset Keyword - Recessed Shadows
  7. Layering Multiple Shadows
  8. Building an Elevation Shadow System
  9. Glow & Highlight Effects
  10. Neumorphism - Soft UI Shadows
  11. Combining box-shadow with border-radius
  12. box-shadow Syntax - Reference Table
  13. Best Practices
  14. Common Mistakes to Avoid
  15. Live Code Example
  16. Try It Yourself - Interactive Editor
  17. 🎨 Interactive Box-Shadow Builder
  18. Practice Quiz
  19. Frequently Asked Questions (FAQ)

✅ What Is CSS box-shadow?

box-shadow draws a shadow shape around (or inside) an element's border box. It's defined by up to four length values, an optional color, and an optional inset keyword — and multiple shadows can be layered together using commas.

↔️
offset-x / y
How far the shadow shifts.
🌫️
blur-radius
How soft the shadow's edges are.
📐
spread-radius
How much bigger/smaller it is.
🔄
inset
Flips the shadow inward.
💡 Key Concept: box-shadow is purely visual, just like border-radius and CSS transforms — it never affects an element's width, height, or position in the page's layout, and never pushes neighboring elements out of the way.

✅ offset-x & offset-y - Positioning the Shadow

The first two length values control how far the shadow shifts: offset-x moves it right (positive) or left (negative), and offset-y moves it down (positive) or up (negative). These two values are the only ones that are required.

offset-x / offset-y - Live Preview
.box-1 {
  box-shadow: 6px 6px black;
}

.box-2 {
  box-shadow: -6px -6px black;
}
👁 Live Output
6px 6px
shifts right & down
-6px -6px
shifts left & up
ℹ️ Default look: With no blur or spread, offset-only shadows render as a hard, sharp-edged duplicate silhouette — useful for retro/flat design styles, but most modern UI adds blur for a softer, more natural look.

✅ blur-radius - Softening the Edges

An optional third value blurs the shadow's edges outward in all directions. Larger numbers create a softer, more spread-out blur; 0 (the default if omitted) produces a hard, sharp-edged shadow.

blur-radius - Live Preview
.box-1 {
  box-shadow: 4px 6px 0 rgba(0,0,0,.3);
}

.box-2 {
  box-shadow: 4px 6px 18px rgba(0,0,0,.3);
}
👁 Live Output
blur: 0
hard edge
blur: 18px
soft edge
⚠️ Common confusion: Blur radius softens edges outward in all directions — it doesn't move the shadow's center position at all, that's still controlled entirely by offset-x and offset-y.

✅ spread-radius - Growing or Shrinking the Shadow

An optional fourth value expands the shadow's shape outward (positive) or shrinks it inward (negative), uniformly on all sides, before the blur is applied. This is different from blur — spread changes the shadow's actual size, not just how soft its edges are.

spread-radius - Live Preview
.box-1 {
  box-shadow: 0 4px 10px 0 rgba(0,0,0,.3);
}

.box-2 {
  box-shadow: 0 4px 10px 10px rgba(0,0,0,.3);
}
👁 Live Output
spread: 0
matches box size
spread: 10px
grows outward
💡 Tip: A small negative spread (like -4px) combined with a larger blur is a common technique for keeping a soft shadow from looking too large or "puffy" directly under the element's exact edges.

✅ Shadow Color & Transparency

Any valid CSS color works, but real-world shadows are rarely fully opaque — using rgba() or hsla() with reduced opacity (like rgba(0,0,0,0.25)) almost always looks more natural than solid black.

Opaque vs Transparent Shadow Color
.box-1 {
  box-shadow: 0 6px 14px black;
}

.box-2 {
  box-shadow: 0 6px 14px rgba(0,0,0,.22);
}
👁 Live Output
solid black
looks heavy / fake
rgba 0.22
looks natural

✅ The inset Keyword - Recessed Shadows

Adding the inset keyword moves the shadow inside the element's border edge instead of outside it, creating a recessed or "pressed-in" appearance — perfect for input fields and pressed-button states.

inset - Live Preview
.outer-shadow {
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

.inset-shadow {
  box-shadow: inset 0 2px 6px rgba(0,0,0,.35);
}
👁 Live Output
normal
raised look
inset
recessed look

✅ Layering Multiple Shadows

box-shadow accepts a comma-separated list of shadow definitions, and all of them render together, layered in the order written. This is the foundation of realistic multi-layer elevation effects.

Multiple Shadows - Live Preview
.card {
  box-shadow:
    0 1px 2px rgba(0,0,0,.08),
    0 4px 8px rgba(0,0,0,.08),
    0 12px 24px rgba(0,0,0,.10);
}
👁 Live Output
layered shadow
ℹ️ Why layer instead of one big shadow? A single large-blur shadow tends to look like a flat, even haze. Three smaller, tighter shadows stacked together (each slightly larger and softer than the last) mimic how real light and shadow actually behave, producing far more convincing depth.

✅ Building an Elevation Shadow System

Many design systems define a small set of "elevation levels" — low, medium, high — each with its own pre-set box-shadow value, so the more "elevated" (closer to the viewer) a component is, the larger and more dramatic its shadow becomes.

Elevation Levels - Live Preview
.elevation-1 { box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.elevation-2 { box-shadow: 0 4px 10px rgba(0,0,0,.18); }
.elevation-3 { box-shadow: 0 12px 28px rgba(0,0,0,.22); }
👁 Live Output
Level 1
Level 2
Level 3

✅ Glow & Highlight Effects

A colorful, zero-offset shadow with a large blur (and sometimes a positive spread) produces a "glow" rather than a drop shadow — popular for buttons, focus states, and dark-themed UI.

Glow Effect - Live Preview
.glow-btn {
  box-shadow:
    0 0 18px 4px rgba(14,165,233,.55);
}
👁 Live Output
glow effect
💡 Tip: Glow effects look best on a darker surrounding background — on a plain white page, a colorful glow shadow can look washed out or barely visible.

✅ Neumorphism - Soft UI Shadows

Neumorphism pairs a light shadow offset up-left with a dark shadow offset down-right, both on a background close to the element's own color — creating the soft, "extruded from the surface" look that became popular in modern soft-UI design.

Neumorphism - Raised vs Pressed
.neu-raised {
  background: #e6e9ef;
  box-shadow:
    -8px -8px 16px #fff,
    8px 8px 16px #c7cad1;
}

.neu-pressed {
  box-shadow:
    inset -6px -6px 12px #fff,
    inset 6px 6px 12px #c7cad1;
}
👁 Live Output
raised
two outer shadows
pressed
two inset shadows
⚠️ Accessibility note: Neumorphic designs rely on very low contrast between the element and its background by design — always double-check text and icon contrast separately, since the shadow alone is not enough to make small text legible.

✅ Combining box-shadow with border-radius

Unlike clipping child content (which needs overflow: hidden), box-shadow automatically follows the exact curve set by border-radius with zero extra code — which is why rounded cards and buttons almost always pair the two.

box-shadow + border-radius - Live Preview
.rounded-card {
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0,0,0,.18);
}
👁 Live Output
rounded shadow

✅ box-shadow Syntax - Reference Table

ValuePositionWhat It Does
offset-x1st (required)Horizontal shift — positive = right, negative = left
offset-y2nd (required)Vertical shift — positive = down, negative = up
blur-radius3rd (optional)Softens the edges; larger = more blur. Default: 0
spread-radius4th (optional)Expands (+) or shrinks (−) the shadow shape. Default: 0
colorany positionShadow color — rgba()/hsla() recommended for realism
insetkeyword, anywhereMoves the shadow inside the border instead of outside
comma-separated listLayers multiple independent shadows together

✅ Best Practices

✔️ 1) Use Semi-Transparent Colors, Not Solid Black
rgba(0,0,0,0.15) to rgba(0,0,0,0.3) covers most realistic use cases far better than fully opaque black.

✔️ 2) Layer Two or Three Shadows for Real Elevation
A tight, low-blur shadow combined with a larger, softer one almost always looks more convincing than a single large shadow.

✔️ 3) Keep a Consistent Elevation Scale Across the Site
Define 2-4 standard shadow values (e.g. card, modal, dropdown) as CSS custom properties so depth feels consistent everywhere.

✔️ 4) Use inset for Pressed/Focused States, Not Regular Cards
Recessed shadows communicate "this is sunken or active" — reserve them for inputs, pressed buttons, and toggled states.

✔️ 5) Test Glow and Neumorphic Shadows on Their Intended Background
Both effects are background-dependent — a glow that pops on dark mode can disappear entirely on a white page, and vice versa.

💡 Pro Tip: Animating only the blur/spread values of box-shadow on :hover (rather than offset) creates a smooth "lift up" effect without any layout shift, since shadows never affect layout regardless.

✅ Common Mistakes to Avoid

❌ Mistake 1 - Using Fully Opaque Black Shadows
Solid black with a small blur looks harsh and artificial — switch to a semi-transparent color for a believable result.
❌ Mistake 2 - Confusing blur-radius and spread-radius
Blur only softens edges outward; spread actually grows or shrinks the shadow's shape before any blur is applied — they solve different problems.
❌ Mistake 3 - Expecting box-shadow to Push Other Elements Away
Like border-radius, box-shadow is purely visual and never affects page layout or spacing, even with a large spread value.
❌ Mistake 4 - Overusing Neumorphism on Low-Contrast Text
The soft, low-contrast surfaces that make neumorphism look elegant can make small text or icons hard to read — always verify contrast separately.
❌ Mistake 5 - Forgetting the Comma Between Multiple Shadows
Missing a comma between two shadow definitions causes the whole box-shadow declaration to become invalid and silently fail to render at all.

✅ Complete Live Example

A product card combining a layered elevation shadow, rounded corners, and a hover-lift effect using only blur and offset changes:

Hover-Lift Product Card - Live Preview
.product-card {
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
  transition: box-shadow .25s, transform .25s;
}

.product-card:hover {
  box-shadow: 0 16px 32px rgba(0,0,0,.20);
  transform: translateY(-4px);
}
👁 Hover the Card
Hover Me 👆

✅ Try It Yourself - Interactive Editor

Edit the HTML and CSS below to experiment with box-shadow. Try layering multiple shadows, adding inset, or building a glow. The preview updates automatically.

🖥 Interactive CSS box-shadow Editor
👁 Live Preview

✅ 🎨 Interactive Box-Shadow Builder

Drag the sliders to combine offset, blur, spread, color, and inset in real time, and watch the box and generated CSS update live.

🎨 CSS box-shadow Builder
PREVIEW
Generated CSS
box-shadow: 0px 10px 20px 0px rgba(0,0,0,0.3);

✅ Practice - Yes / No Quiz

1. Are offset-x and offset-y the only two values required for a valid box-shadow?

2. Does increasing spread-radius soften the shadow's edges, the same way blur-radius does?

3. Does the inset keyword move the shadow inside the element's border instead of outside it?

4. Can box-shadow accept a comma-separated list to layer multiple shadows on one element?

5. Does box-shadow change an element's width, height, or position in the page's layout?

0/5
Your Score - Keep Practising! 🎯

✅ Frequently Asked Questions (FAQ)

What are the four length values in box-shadow for?
The first value is the horizontal offset (offset-x), the second is the vertical offset (offset-y), the third (optional) is the blur radius, and the fourth (optional) is the spread radius. Only offset-x and offset-y are required — blur and spread both default to 0 if omitted.
What is the difference between blur-radius and spread-radius?
blur-radius softens the shadow's edges by blurring them outward in both directions, like a glow. spread-radius expands or shrinks the entire shadow shape uniformly before any blurring happens — a positive spread makes the shadow bigger than the element on all sides, while a negative spread makes it smaller.
What does the inset keyword do in box-shadow?
Adding inset to a box-shadow declaration moves the shadow inside the element's border edge instead of outside it, creating a recessed or pressed-in appearance. This is commonly used for input fields, pressed buttons, and neumorphic "sunken panel" designs.
Can an element have more than one box-shadow at once?
Yes. box-shadow accepts a comma-separated list of shadow definitions, and all of them render together, layered on top of each other in the order written. This is exactly how realistic multi-layer elevation shadows and neumorphic effects are built — combining a soft, far-reaching shadow with a tighter, closer one.
Why does my box-shadow look too harsh or fake?
The most common cause is using a fully opaque color like black with a small blur radius. Real-world shadows are soft and semi-transparent — switching to a color like rgba(0,0,0,0.2) and increasing the blur radius almost always produces a more natural, believable result.
Does box-shadow affect an element's layout or take up space?
No. box-shadow is purely visual and never affects the element's width, height, or position in the page's layout, nor does it push sibling elements away — it can, however, visually overlap neighboring content if the shadow is large enough.
✍️ About the Author - Pramod Behera

Pramod Behera is the founder of LearnToSAP.com and an experienced web development educator. He creates beginner-friendly tutorials on HTML, CSS, SAP SD/MM, and frontend development, helping thousands of learners worldwide build practical skills.