Style letterSpacing attribute
- 上一页 left
- 下一页 lineHeight
- 返回上一层 Inayotukia Style ya HTML DOM
Definition and usage
letterSpacing
Attribute sets or returns the spacing between characters in the text (character spacing).
Tip:To set or return the spacing between words in the text (word spacing), use wordSpacing property.
See also:
CSS Tutorial:Matukio ya CSS wa Kifaa
CSS Reference Manual:letter-spacing property
Instance
Example 1
Set the spacing between characters in the <p> element to 15 pixels:
document.getElementById("myP").style.letterSpacing = "15px";
Example 2
Use negative values:
document.getElementById("myP").style.letterSpacing = "-2px";
Example 3
Return the letter spacing of the <p> element:
alert(document.getElementById("myP").style.letterSpacing);
Example 4
Difference between letterSpacing property and wordSpacing property:
function changeLetters() { document.getElementById("myP1").style.letterSpacing = "15px"; } function changeWords() { document.getElementById("myP2").style.wordSpacing = "15px"; }
Syntax
Return letterSpacing property:
object.style.letterSpacing
Set letterSpacing property:
object.style.letterSpacing = "normal|length|initial|inherit"
Attribute value
Value | Description |
---|---|
normal | Normal spacing between characters. Default. |
length | Define spacing with length units. Negative values are allowed. |
initial | Set this property to its default value. See initial. |
inherit | Inherit this property from its parent element. See inherit. |
Technical details
Default value: | normal |
---|---|
Return value: | String, representing the spacing between characters in the text. |
CSS Version: | CSS1 |
浏览器支持
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 |
- 上一页 left
- 下一页 lineHeight
- 返回上一层 Inayotukia Style ya HTML DOM