CSS Portal

CSS text-shadow Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The text-shadow property applies one or more shadow effects to the glyphs of text, creating the illusion of depth, glow, blur, or outline around letters. Shadows are painted relative to each glyph so they follow the shape of the characters (including inner contours of letters like “o” or “e”), and multiple shadows can be layered to produce complex visual treatments. Because the effect is applied to the text itself rather than the box that contains it, it’s especially useful when you need the shadow to conform tightly to letter shapes rather than to the element’s rectangle.

Designers use text-shadow for a wide variety of typographic enhancements: subtle drop shadows to improve legibility against textured backgrounds, soft glows for neon-like effects, inset or embossed looks to suggest surface depth, and faux outlines by stacking shadows. When choosing shadow color and contrast with the text you’ll often coordinate it with the element’s foreground color—see color—and with overall layout so the shadow reads correctly at the text’s size and weight. It also pairs visually with box-level effects such as box-shadow when both the text and its container need complementary depth cues.

Keep in mind practical and accessibility considerations: heavy, blurred, or multi-layered shadows can reduce legibility—especially at small sizes or for users with visual impairments—so use them sparingly or increase contrast and sizing when needed. Shadows interact with how type is rendered, so results can vary with different fonts and with properties such as font-size; display and decorative fonts tolerate more extreme treatments than fine text. Also consider performance and responsiveness: many costly shadow effects or animated shadow changes can increase rendering work on the GPU, so test on target devices and simplify effects where smoothness matters.

Finally, because text-shadow is a purely decorative property, it’s often combined thoughtfully with typographic and layout choices rather than relied on for meaning. Use it to support hierarchy and emphasis, not to convey essential information by itself. When designing for different backgrounds or themes, you may prefer subtler shadowing or none at all and rely on contrast and spacing (typographic choices) to maintain clarity.

Definition

Initial value
none
Applies to
All elements
Inherited
Yes
Computed value
A color plus three absolute lengths
Animatable
Yes
JavaScript syntax
object.style.textShadow

Interactive Demo

The rusty swing set creaked a lonely lullaby in the twilight, shadows lengthening like grasping fingers across the dew-kissed grass.

Syntax

text-shadow: none | <length>{2,3} && <color>

Values

  • noneNo shadow is applied.
  • <length>This is a <length> value. The first value represents offset-x and the second value represents offset-y, these values are required. The third value represents the blur radius, the higher the value, the bigger the blur; the shadow becomes wider and lighter. If not specified, it defaults to 0.
  • <color>Optional. Can be specified either before or after the offset values. If the color is not specified, a browser chosen color will be used.

Example

<div class="wrap">
<h1 class="single">Single shadow</h1>
<h2 class="multi">Multiple layered shadow</h2>
<p class="glow">Soft glow shadow</p>
</div>
.wrap {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding: 40px;
    text-align: center;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    min-height: 100vh;
    box-sizing: border-box;
}

.single {
    font-size: 48px;
    color: #222;
    text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.15);
    margin: 0 0 20px;
}

.multi {
    font-size: 36px;
    color: #1a73e8;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.10), 6px 6px 12px rgba(0, 0, 0, 0.15);
    margin: 0 0 20px;
}

.glow {
    font-size: 20px;
    color: #fff;
    background: #ff6b6b;
    display: inline-block;
    padding: 8px 14px;
    border-radius: 6px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.20), 0 0 10px rgba(255, 255, 255, 0.30);
}

Browser Support

The following information will show you the current browser support for the CSS text-shadow property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!