Style letterSpacingProperty

Style 对象参考手册Style Object

Definition and Usage

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

Syntax

Set the letterSpacing property:

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

Return the letterSpacing property:

Object.style.letterSpacing

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the letterSpacing property.

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


Example

Example

Change the space between characters:

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

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

</body>
</html>

Try it Yourself »


Style 对象参考手册Style Object Other Extensions