CSS Shadow Effects

With CSS you can add shadow to text and to elements.In this chapter you will learn about the following properties:

  • text-shadow
  • box-shadow

CSS Text Shadow

The text-shadow CSS property adds shadows to text. It accepts a comma-separated list of shadows to be applied to the text and any of its decorations. Each shadow is described by some combination of X and Y offsets from the element, blur radius, and color.

The CSS3 text-shadow property is one of the most popular techniques of progressively enhancing the design of a website. Although it was originally in the CSS 2.1 specification, it was withdrawn due to lack of support. However it is now back in CSS 3 and has widespread support amongst modern browsers.

Example -

Text shadow effect!

Add any color to the shadow and gave nice look to your text.

Then, add a blur effect to the shadow:

The following example shows a white text with black shadow:

The following example shows a red neon glow shadow:

Burning Text Effect

Multiple Shadows

To add more than one shadow to the text, you can add a comma-separated list of shadows.

Border around text!

CSS box-shadow Property

The box-shadow CSS property is used to add shadow effects around an element's frame. You can specify multiple effects separated by commas if you wish to do so. A box shadow is described by X and Y offsets relative to the element, blur and spread radii, and color.

The CSS box-shadow property applies shadow to elements.In its simplest use, you only specify the horizontal shadow and the vertical shadow:

Images with shadow effect

A box shadow property allows us to draw a shadow behind an element.