Style letterSpacing attribute
- Föregående sida left
- Nästa sida lineHeight
- Gå tillbaka till föregående nivå HTML DOM Style objekt
Definition and Usage
letterSpacing
Attribute to set or return 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:CSS-text
CSS Reference Manual:letter-spacing property
Instance
Example 1
Sets 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
Returns 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 | Defined by length units. Allows negative values. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical details
Default value: | normal |
---|---|
Return value: | A string that represents the spacing between characters in the text. |
CSS version: | CSS1 |
Webbläsarstöd
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Stöd | Stöd | Stöd | Stöd | Stöd |
- Föregående sida left
- Nästa sida lineHeight
- Gå tillbaka till föregående nivå HTML DOM Style objekt