Stijl letterSpacing Property
Voorbeeld
Stel de ruimte tussen tekens in een element in op 15 pixels:
document.getElementById("demo").style.letterSpacing = "15px";
Definitie en gebruik
Met de eigenschap letterSpacing wordt de spatie tussen tekens in een tekst ingesteld of geretourneerd.
Tip: gebruik de eigenschap wordSpacing om de afstand tussen woorden in een tekst in te stellen of terug te geven .
Browserondersteuning
Property | |||||
---|---|---|---|---|---|
letterSpacing | Yes | Yes | Yes | Yes | Yes |
Syntaxis
Retourneer de eigenschap letterSpacing:
object.style.letterSpacing
Stel de eigenschap letterSpacing in:
object.style.letterSpacing = "normal|length|initial|inherit"
Eigendomswaarden
Value | Description |
---|---|
normal | Normal space between characters. This is default |
length | Defines the space in length units. Negative values are allowed |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technische details
Standaardwaarde: | normaal |
---|---|
Winstwaarde: | Een tekenreeks, die de ruimte tussen tekens in de tekst vertegenwoordigt |
CSS-versie | CSS1 |
Meer voorbeelden
Voorbeeld
Negatieve waarden gebruiken:
document.getElementById("demo").style.letterSpacing = "-2px";
Voorbeeld
Retourneer de letterafstand van een element:
alert(document.getElementById("demo").style.letterSpacing);
Voorbeeld
Verschil tussen de eigenschap letterSpacing en de eigenschap wordSpacing:
function changeLetters() {
document.getElementById("demo1").style.letterSpacing = "15px";
}
function changeWords() {
document.getElementById("demo2").style.wordSpacing = "15px";
}
Gerelateerde pagina's
CSS-zelfstudie: CSS-tekst
CSS -referentie: eigenschap voor letterafstand
❮ Stijlobject