HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

CSS Tutorial

CSS Introduction

What is CSSCSS SyntaxHow to Add CSSCSS Comments

CSS Foundations

Cascade & InheritanceCSS SpecificityCSS UnitsBox SizingCSS VariablesCSS Math Functions

CSS Selectors

CSS Element SelectorCSS Class SelectorCSS ID SelectorCSS Universal SelectorCSS Group SelectorCSS CombinatorsCSS Attribute SelectorsCSS Pseudo ClassesCSS Pseudo Elements

CSS Colors and Backgrounds

CSS ColorsCSS HEX ColorsCSS RGB ColorsModern ColorsCSS Background ColorCSS Background ImageLayered Backgrounds

CSS Text & Fonts

CSS Text ColorCSS Text AlignmentCSS Text DecorationCSS Font FamilyCSS Font SizeWeb Fonts & TypographyText Wrapping

CSS Box Model

CSS MarginCSS PaddingCSS BorderCSS OutlineCSS Width and Height

CSS Layout

Normal FlowCSS DisplayCSS PositionAnchor PositioningCSS FloatCSS OverflowCSS Z-indexIntrinsic SizingAspect Ratio & Object FitMulti-column Layout

CSS Flexbox

Flex ContainerFlex DirectionJustify ContentAlign ItemsFlex WrapFlex Item Sizing

CSS Grid

CSS Grid ContainerCSS Grid ColumnsCSS Grid RowsCSS Grid GapCSS Grid Layout ExampleGrid PlacementGrid AreasCSS Subgrid

CSS Lists, Tables & Forms

CSS ListsCSS TablesCSS Form StylingCSS Input Fields

CSS Effects

CSS ShadowsCSS GradientsCSS FiltersCSS OpacityClipping & MaskingBlending & BackdropScroll Snap

CSS Animations & Transitions

CSS TransformCSS 2D TransformCSS 3D TransformCSS TransitionsEntry & Exit TransitionsCSS AnimationsScroll AnimationsView TransitionsMotion Paths

CSS Responsive Design

CSS Media QueriesResponsive LayoutMobile First DesignContainer QueriesPreference Media QueriesFeature Queries

Modern CSS Authoring

Cascade LayersNesting & ScopeLogical PropertiesGenerated Content

CSS Accessibility

Accessible CSSCSS ThemingModern Form StylingCSS User Interface

CSS Output & Performance

Print StylesCSS PerformanceCSS ArchitectureDebugging CSS

CSS Reference

CSS At-rulesCSS FunctionsCSS Tutorial PDF

CSS Projects

Responsive CSS Project
  1. Home
  2. /
  3. Tutorials
  4. /
  5. CSS Tutorial
  6. /
  7. CSS Shadows

CSS Effects

CSS Shadows

The CSS Shadows properties are used to add shadow effects to elements and text on a webpage.

Shadows help create:

  • Depth and dimension
  • Visual emphasis
  • Modern UI designs
  • Better content separation

CSS provides two main shadow properties:

  • box-shadow -> Adds shadows to elements
  • text-shadow -> Adds shadows to text

Shadows are widely used in cards, buttons, images, modals, and typography. The supporting concepts are explained in CSS Opacity and CSS Filters.

Syntax

Box Shadow

Box Shadow Syntax

css

selector {
    box-shadow: horizontal vertical blur color;
}

Box Shadow Example

css

div {
    box-shadow: 5px 5px 10px gray;
}

Adds a shadow to the element.

Text Shadow

Text Shadow Syntax

css

selector {
    text-shadow: horizontal vertical blur color;
}

Text Shadow Example

css

h1 {
    text-shadow: 2px 2px 5px gray;
}

Adds a shadow to the text.

Attributes

PropertyDescriptionExample
box-shadowAdds shadow to an elementbox-shadow: 5px 5px 10px gray;
text-shadowAdds shadow to texttext-shadow: 2px 2px 5px black;
horizontal offsetMoves shadow left/right5px
vertical offsetMoves shadow up/down5px
blur radiusControls shadow softness10px

Example

CSS Shadows Complete Example

html

<!DOCTYPE html>
<html>
<head>
    <title>CSS Shadows Example</title>
    <style>
        .card {
            width: 250px;
            padding: 20px;
            margin: 20px;
            background-color: white;
            box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.3);
        }
        h1 {
            text-shadow: 2px 2px 5px gray;
        }
    </style>
</head>
<body>
    <h1>CSS Shadows</h1>
    <div class="card">
        This card uses a box shadow.
    </div>
</body>
</html>

Browser Support

Feature
Chrome
Edge
Firefox
Safari
box-shadow101245.1

Versions show the first stable desktop release with unprefixed support. Data source: MDN Browser Compatibility Data 8.0.8.

Notes

  • Positive horizontal values move shadows to the right.
  • Positive vertical values move shadows downward.
  • Higher blur values create softer shadows.
  • Multiple shadows can be applied.

Box Shadow Structure

Box Shadow Structure

css

box-shadow: offset-x offset-y blur-radius color;

Multiple Shadows

Multiple Shadows Example

css

box-shadow:
    2px 2px 5px gray,
    5px 5px 15px lightgray;

Inset Shadow

Inset Shadow Example

css

box-shadow: inset 0 0 10px gray;

Creates a shadow inside the element.

Text Shadow Example

Text Shadow Example

css

text-shadow: 3px 3px 5px #999;

Conclusion

CSS Shadows help create depth, emphasis, and modern visual effects on web pages. By using box-shadow and text-shadow, you can enhance UI components, improve readability, and create more attractive designs with minimal effort.

PreviousCSS Input FieldsNextCSS Gradients