CSS Property: text-shadow
[this page | pdf | back links]
The CSS (CSS3) text-shadow property indicates what
shadow should be added to text. To add more than one shadow, the property
should be set to a comma-separated list of shadows.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
none
|
(default value). No
shadow
|
h-shadow v-shadow
blur-radius color
|
2 to 4 parameters:
-
h-shadow (required): position of horizontal shadow (can be
negative)
-
v-shadow (required): position of vertical shadow (can be
negative)
-
blur-radius (optional): how fuzzy (default is zero)
-
color (optional): CSS colour of shadow
(default is colour of text)
|
Default Value:
|
none
|
JavaScript syntax:
|
e.g. object.style.textShadow="2px 10px 5px blue"
|
Inherited:
|
Yes
|
Animatable:
|
Yes
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 100px; height: 15px; border: thin solid green;}
.x1 {text-shadow: 2px 10px 2px blue}
</style>
</head>
<body>
1. Element with default property<br>
<div>abcdefgh</div><br><br>
2. Element set using in-file HTML style<br>
<div class="x1">abcdefgh</div><br><br>
3. Element set using JavaScript<br>
<div id="x2">abcdefgh</div>
<script>
document.getElementById("x2").style.textShadow = "2px 10px 2px blue";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyTextShadow() {
var x = document.createElement("DIV"); x.style.textShadow = "2px 10px 2px blue"; return (window.getComputedStyle(x, null).textShadow == "2px 10px 2px blue");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties