Style wordSpacingProperty

Style 对象参考手册Style Object

Definition and Usage

The wordSpacing property sets or returns the space between words in text.

Syntax

Set the wordSpacing property:

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

Return the wordSpacing property:

Object.style.wordSpacing

Value Description
normal Default. Defines the standard space between words.
length Defines the space between words using units such as px, cm, etc. Negative values are allowed.
inherit The value of the wordSpacing property is inherited from the parent element.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the wordSpacing property.

Note:IE7 and earlier versions do not support the "inherit" value. IE8 only supports "inherit" if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Change the space between words:

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

<p id="p1">This is some text.</p>
<br>
<button type="button" onclick="displayResult()">Modify Space</button>

</body>
</html>

Try it Yourself »


Style 对象参考手册Style Object Other Extensions