Open In App

How to set inner text shadow with CSS ?

CSS is a style sheet language that describes the document’s presentation written with HTML or similar markup languages. In this tutorial, we are going to learn how to set inner text shadows with CSS.

Approach: Text shadow is used to design the text elements such as paragraphs, headings, etc. We first set the background color and made the text color transparent. Then we clip the background according to the text to get that part only. Finally, we put the blurred text-shadow in front of the text which gives the inner text-shadow.



Syntax of inner text-shadow:

text-shadow: offset-x | offset-y | blur-radius | colour
background-clip: text;
color: transparent;

Example: In the following example shows the inner text shadow with zero offsets on both axes.






<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport"
          content="width=device-width,
                   initial-scale=1.0" />
    <style>
        .inner {
            background-color: #565656;
            font: bold 48px 'Futura';
            color: transparent;
            text-shadow: 0px 0px 3px rgba(91, 255, 76, 0.8);
            -webkit-background-clip: text;
            -moz-background-clip: text;
            background-clip: text;
        }
    </style>
</head>
 
<body>
    <center>
        <div>
            <h1 style="color: green;">
                GeeksforGeeks
            </h1>
        </div>
        <strong>
            How to set inner text shadow with CSS ?
        </strong>
        <br />
        <br />
        <p class="inner">
            Welcome to GeeksforGeeks
        </p>
 
    </center>
</body>
</html>

Output

 


Article Tags :