You are here: Reference > JavaScript > client-side > style handling > properties > textShadow

textShadow style property

Browser support:
3.5
Specifies or returns a comma-separated list of shadow effects to be applied to the text of the element.
Note: The textShadow property is supported in Firefox from version 3.5.

Syntax:

object.textShadow;
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: text-shadow

Possible values:

The type of this property is string.
 One of the following values: 
 This value can be used arbitrary times (use the , character to separate them) 
 Values in this order (use the space character to separate them): 
1.
<color> possible but not necessary; left to personal choice
2. <horizontal offset in length>
3. <vertical offset in length>
4.
<blur radius in non-negative length> possible but not necessary; left to personal choice
none
inherit

Description of values:

blur radius in non-negative length
The blur radius of the shadow in length units, 0 value means sharp, larger values mean the shadow is blurred. For the supported length units, see the length page.
color
The color of the shadow, if not specified, the value of the color property is used. For the supported color values, see the colors page.
horizontal offset in length
The horizontal offset of the shadow from the text in length units. For the supported length units, see the length page.
inherit
Takes the value of this property from the computed style of the parent element.
none
Default. No shadow is drawn.
vertical offset in length
The vertical offset of the shadow from the text in length units. For the supported length units, see the length page.
Default: none.

Example HTML code 1:

This example illustrates the use of the text-shadow property:
<head>
    <style>
        .example {
            text-shadow: green 4px 4px, blue -4px -4px;
        }
    </style>
</head>
<body>
    <p class="example">text shadow</p>
</body>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the textShadow property in JavaScript:
<head>
    <style>
        .example {
            text-shadow: green 4px 4px, blue -4px -4px;
        }
        .example2 {
            text-shadow: red 4px 4px;
        }
    </style>
    <script type="text/javascript">
        function ChangeShadow (elem) {
            elem.className = "example2";

            // Solve Opera refresh problems
            if (window.opera) {
                var next = elem.nextSibling;
                var par = elem.parentElement;
                par.removeChild (elem);
                par.insertBefore (elem, next);
            }
        }
    </script>
</head>
<body>
    <p class="example" onclick="ChangeShadow (this);">Click to change!</p>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content