HTML DOM Style textShadow Property


The HTML DOM style textShadow property returns and apply what should happen when the text flow outside the element container in an HTML document.

Syntax

Following is the syntax −

  • Returning textShadow

object.style.textShadow
  • Modifying textShadow

object.style.textShadow = “value”

Values

Here, value can be −

ValueExplanation
inheritIt inherits this property value from its parent element.
initialIt set this property value to its default value.
noneIt sets no shadow on text.
h-shadow v-shadow blur colorIt sets shadow on text.
Here
h-shadow represent the value of horizontal shadow.
v-shadow represent the value of vertical shadow.
blur represent the blur distance.
color represent the color of the shadow.

Example

Let us see an example of style textShadow property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
   body {
      color: #000;
      background: lightblue;
      height: 100vh;
   }
   p {
      margin: 1.5rem auto;
   }
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
   }
</style>
</head>
<body>
<h1>DOM Style textShadow Property Example</h1>
<p>Some Dummy Text</p>
<button onclick="add()" class="btn">Set textShadow</button>
<script>
   function add() {
      document.querySelector('p').style.textShadow = "10px 10px 2px #db133a";
   }
</script>
</body>
</html>

Output

This will produce the following output −

Click on “Set textShadow” button to apply shadow on paragraph text.

Updated on: 01-Jul-2020

24 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements