
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
How to Apply Shadow Effect on Text Using CSS?
We can apply a shadow effect on a text element using the “text-shadow” property given by CSS. The “text-shadow” property takes a list of values that represents X and Y offsets of the shadow from the element, the blur radius of the shadow, and the color of the shadow. These values are listed in the syntax below −
Syntax
text-shadow: offset_y offset_x blur-radius color
Here the values and their meanings are listed below −
Offset-x − It represents the distance of the shadow from the element in the horizontal direction
Offset-y − It represents the distance of the shadow from the element in the vertical direction
Blur radius − It represents the opacity of the shadow
Color − It represents the color of the shadow
Example 1
In this example, we will apply the shadow effect on an “h3” element and give the shadow a y-offset along with red color
<!DOCTYPE html> <html lang="en"> <head> <title>How to Apply Shadow Effect on Text Using CSS?</title> <style> h3 { text-shadow: 0 15px 0 red; } </style> </head> <body> <h3>How to Apply Shadow Effect on Text Using CSS?</h3> </body> </html>
Example 2
In this example, we will apply the shadow effect on an “h3” element and give the shadow a y-offset, an x-offset, an opacity, and a green color.
<!DOCTYPE html> <html lang="en"> <head> <title>How to Apply Shadow Effect on Text Using CSS?</title> <style> h3 { text-shadow: 10px 15px 5px green; } </style> </head> <body> <h3>How to Apply Shadow Effect on Text Using CSS?</h3> </body> </html>
Conclusion
In this article, we learned the “text-shadow” property is, and we used it to apply a shadow effect on a text element using CSS, with the help of 2 different examples. In the first example, we applied a vertical shadow effect of the “red” color, and in the second example, we applied a vertical and a horizontal shadow effect of the “green” color having a blur-radius of 5px.
- Related Articles
- CSS Shadow Effect
- How to create Text Split effect using CSS?
- CSS Text Shadow
- Loading Text Animation Effect using CSS
- How to add shadow Effect for a Text in Android?
- Create white text with black shadow using CSS
- Set Drop Shadow Effect with CSS
- How to set the shadow effect of a text with JavaScript?
- How to add shadow on text swift?
- Animate CSS text-shadow property
- How to Create Text Reveal Effect for Buttons using HTML and CSS?
- Add shadow effects to text with CSS
- Add a blur effect to the shadow with CSS
- How to add a drop shadow effect to a text node in JavaFX?
- How to add an inner shadow effect to a text node in JavaFX?
