Style letterSpacing attribute
- Poprzednia strona left
- Następna strona lineHeight
- Wróć do poprzedniego poziomu Obiekt Style HTML DOM
Definition and usage
letterSpacing
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 attribute.
See also:
CSS Tutorial:Tekst CSS
CSS Reference Manual:letter-spacing attribute
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 and wordSpacing properties:
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: | String that represents the spacing between characters in the text. |
CSS Version: | CSS1 |
Obsługa przeglądarek
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Wsparcie | Wsparcie | Wsparcie | Wsparcie | Wsparcie |
- Poprzednia strona left
- Następna strona lineHeight
- Wróć do poprzedniego poziomu Obiekt Style HTML DOM