Stile letterSpacing Proprietà
Esempio
Imposta lo spazio tra i caratteri in un elemento su 15 pixel:
document.getElementById("demo").style.letterSpacing = "15px";
Definizione e utilizzo
La proprietà letterSpacing imposta o restituisce lo spazio tra i caratteri in un testo.
Suggerimento: per impostare o restituire la spaziatura tra le parole in un testo, utilizzare la proprietà wordSpacing .
Supporto browser
Property | |||||
---|---|---|---|---|---|
letterSpacing | Yes | Yes | Yes | Yes | Yes |
Sintassi
Restituisce la proprietà letterSpacing:
object.style.letterSpacing
Imposta la proprietà letterSpacing:
object.style.letterSpacing = "normal|length|initial|inherit"
Valori di proprietà
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 |
Dettagli tecnici
Valore di default: | normale |
---|---|
Valore di ritorno: | Una stringa, che rappresenta lo spazio tra i caratteri nel testo |
Versione CSS | CSS1 |
Altri esempi
Esempio
Usando valori negativi:
document.getElementById("demo").style.letterSpacing = "-2px";
Esempio
Restituisce la spaziatura delle lettere di un elemento:
alert(document.getElementById("demo").style.letterSpacing);
Esempio
Differenza tra la proprietà letterSpacing e la proprietà wordSpacing:
function changeLetters() {
document.getElementById("demo1").style.letterSpacing = "15px";
}
function changeWords() {
document.getElementById("demo2").style.wordSpacing = "15px";
}
Pagine correlate
Tutorial CSS: testo CSS
Riferimento CSS: proprietà di spaziatura delle lettere
❮ Oggetto stile