letter-spacing
defines the amount of whitespace between the characters.
Item | Value |
---|---|
Initial value | normal |
Inherited | No. |
Version | CSS1 |
JavaScript syntax | object.style.letterSpacing="3px" |
Applies to | All elements. |
letter-spacing: length | normal | inherit
The property values are listed in the following table.
Value | Description |
---|---|
normal | Default value. No extra space between characters. |
length | Set an extra space between characters and negative values are allowed |
inherit | Inherit the letter-spacing property from the parent element |
letter-spacing |
Yes | Yes | Yes | Yes | Yes |
The following code uses px
and em
based value to set letter_spacing
.
p {letter-spacing: 6px;} em {letter-spacing: 0.2em;} p {letter-spacing: -0.5em;}
<!DOCTYPE HTML>
<html>
<head>
<style>
p {<!-- ww w. ja v a 2s. co m-->
letter-spacing: -2px;
}
</style>
</head>
<body>
<p>
Two pixels of space have been
subtracted from between each letter.
</p>
</body>
</html>
letter-spacing
sets the space between letters.
Its value can be:normal
or CSS length value.
<!-- w w w .j av a2 s . co m-->
<html>
<head>
<style rel="stylesheet" type="text/css">
p.normal {
letter-spacing: normal;
}
p.wide {
letter-spacing: 1.5em;
}
p.narrow {
letter-spacing: -.2ex;
}
</style>
</head>
<body>
<p class="normal">This paragraph has normal letter-spacing.</p>
<p class="wide">This paragraph uses a 1.5em letter-spacing.</p>
<p class="narrow">This paragraph uses a -.2ex letter-spacing.</p>
</body>
</html>