CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



CSS Text Effects

CSS Text Effects are a set of techniques used to enhance the appearance of text on a web page. These effects can be used to make text more visually appealing, easier to read, and more engaging for users. CSS Text Effects can be applied to any text element on a web page, including headings, paragraphs, and links.

Brief Explanation of CSS Text Effects

CSS Text Effects can be achieved using a variety of CSS properties and values. Some of the most commonly used CSS Text Effects include:

  • Text Shadow: This effect adds a shadow to the text, making it appear as if it is floating above the background.
  • Text Stroke: This effect adds an outline to the text, making it stand out from the background.
  • Text Gradient: This effect adds a gradient to the text, making it appear as if it is fading from one color to another.
  • Text Glow: This effect adds a glowing effect to the text, making it appear as if it is emitting light.
  • Text Animation: This effect adds animation to the text, making it move or change in some way.

Code Examples

Here are some examples of how to apply CSS Text Effects to your web page:

Text Shadow

To add a text shadow to your text, use the text-shadow property:

  <p style="text-shadow: 2px 2px 5px #000000;">This text has a shadow.</p>

This will add a shadow to the text, with a horizontal offset of 2 pixels, a vertical offset of 2 pixels, a blur radius of 5 pixels, and a color of black.

Text Stroke

To add a text stroke to your text, use the -webkit-text-stroke property:

  <p style="-webkit-text-stroke: 1px black;">This text has a stroke.</p>

This will add a stroke to the text, with a width of 1 pixel and a color of black.

Text Gradient

To add a text gradient to your text, use the background-clip and text-fill-color properties:

  <p style="background: linear-gradient(to right, #ff0000, #0000ff); -webkit-background-clip: text; -webkit-text-fill-color: transparent;">This text has a gradient.</p>

This will add a gradient to the text, with a start color of red and an end color of blue, fading from left to right.

Text Glow

To add a text glow to your text, use the text-shadow property with a larger blur radius:

  <p style="text-shadow: 0 0 10px #ffffff, 0 0 20px #ffffff, 0 0 30px #ffffff;">This text has a glow.</p>

This will add a glow to the text, with three shadows of increasing blur radius and a color of white.

Text Animation

To add a text animation to your text, use the @keyframes rule and the animation property:

  @keyframes example {
    0% { color: red; }
    50% { color: blue; }
    100% { color: green; }
  }

  <p style="animation: example 5s infinite;">This text is animated.</p>

This will add an animation to the text, with a color change from red to blue to green over a 5 second period, repeating indefinitely.

References

Activity