Latest web development tutorials

HTML DOM Style letterSpacing property

Style Object Reference Style Objects

Definition and Usage

letterSpacing property sets or returns the space between characters in the text.

grammar

Setting letterSpacing properties:

Object.style.letterSpacing="normal|length|inherit"

Back letterSpacing properties:

Object.style.letterSpacing

描述
normal 默认。定义字符间的标准空间。
length 使用 px、cm 等单位定义字符间的空间。可使用负值。
inherit letterSpacing 属性的值从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support letterSpacing property.

Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".


Examples

Examples

Changing the space between characters:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    document.getElementById("p1").style.letterSpacing="15px";
}
</script>
</head>
<body>

<p id="p1">这是一些文本。</p>
<br>
<button type="button" onclick="displayResult()">修改字符间间距</button>

</body>
</html>

try it"


Style Object Reference Style Objects