CSS text-shadow Property


The CSS text-shadow property is used to add shadows to the text. You can choose colors from here: HTML colors.

The text-shadow property is one of the CSS3 properties.

Each shadow is specified by 2 to 3 length values and a <color>. The first value sets the horizontal distance(x-offset), the second value sets the vertical distance(y-offset), the third value sets the blur radius and color value sets the shadow color.

Initial Valuenone
Applies toAll elements. It also applies to ::first-letter and ::first-line.
InheritedYes.
AnimatableYes.
VersionCSS3
DOM Syntaxobject.style.textShadow = “1px 3px 3px #8ebf42”;

Syntax

text-shadow: h-shadow v-shadow blur-radius color | none | initial | inherit;

Example of the text-shadow property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .shadow {
        text-shadow: 2px 2px #1c87c9;
      }
    </style>
  </head>
  <body>
    <h2>Text-shadow property example</h2>
    <p>Some paragraph for example.</p>
    <p class="shadow">Some paragraph with the text-shadow property.</p>
  </body>
</html>

Result

CSS text-shadow Property

Example of the text-shadow property with the “x-offset”, “y-offset”, “blur-radius” and “color” values:

<!DOCTYPE html>
<html>
  <head>
    <style>
      p {
        text-shadow: 5px 3px 2px #8ebf42;
        font: 1em Roboto, Helvetica, sans-serif;
      }
    </style>
  </head>
  <body>
    <h2>Text-shadow property example</h2>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
  </body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *