Style wordSpacing 屬性

Style 對象參考手冊 Style 對象

定義和用法

wordSpacing 屬性設置或返回文本中單詞之間的空間。

語法

設置 wordSpacing 屬性:

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

返回 wordSpacing 屬性:

Object.style.wordSpacing

描述
normal 默認。定義單詞間的標準空間。
length 使用 px、cm 等單位定義單詞間的空間。可使用負值。
inherit wordSpacing 屬性的值從父元素繼承。


流覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要流覽器都支持 wordSpacing 屬性。

注意:IE7 及更早的版本不支持 "inherit" 值。IE8 只有規定了 !DOCTYPE 才支持 "inherit"。IE9 支持 "inherit"。


實例

實例

更改單詞間的空間:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
<script>
function displayResult(){
    document.getElementById("p1").style.wordSpacing="50px";
}
</script>
</head>
<body>

<p id="p1">這 是 一 些 文 本。</p>
<br>
<button type="button" onclick="displayResult()">修改空間</button>

</body>
</html>



Style 對象參考手冊 Style 對象