Latest web development tutorials

HTML DOM Style textShadow property

Style Object Reference Style Objects

Definition and Usage

textShadow property sets or returns one or more text shadow effect.

grammar

Setting textShadow properties:

Object.style.textShadow="none|h-shadow v-shadow blur color|inherit"

Note: textShadow or more additional attributes to the text of a shadow.The property is a comma-separated list of shadow, and an optional value for each color is specified by 2 or 3 length value. Length of zero is omitted.

Back textShadow properties:

Object.style.textShadow

描述
none 默认。没有阴影绘制。
h-shadow 必需。水平阴影的位置。可使用负值。
v-shadow 必需。垂直阴影的位置。可使用负值。
blur 可选。模糊距离。
color 可选。阴影的颜色。在 CSS 颜色值 中寻找可能的颜色值的完整列表。
inherit textShadow 属性的值从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support textShadow property, in addition to Internet Explorer.


Examples

Examples

To add text shadows:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    document.getElementById("p1").style.textShadow="5px 5px 1px #ff0000,10px 10px 1px #0000ff";
}
</script>
</head>
<body>

<p id="p1">这是一些文本。</p>
<br>
<button type="button" onclick="displayResult()">添加文本的阴影</button>

</body>
</html>

try it"


Style Object Reference Style Objects