Estilo letterSpacing Propiedad
Ejemplo
Establezca el espacio entre caracteres en un elemento en 15 píxeles:
document.getElementById("demo").style.letterSpacing = "15px";
Definición y uso
La propiedad letterSpacing establece o devuelve el espacio entre caracteres en un texto.
Sugerencia: para establecer o devolver el espacio entre palabras en un texto, use la propiedad wordSpacing .
Compatibilidad con navegador
Property | |||||
---|---|---|---|---|---|
letterSpacing | Yes | Yes | Yes | Yes | Yes |
Sintaxis
Devuelve la propiedad letterSpacing:
object.style.letterSpacing
Establezca la propiedad letterSpacing:
object.style.letterSpacing = "normal|length|initial|inherit"
Valores de propiedad
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 |
Detalles técnicos
Valor por defecto: | normal |
---|---|
Valor de retorno: | Una cadena, que representa el espacio entre caracteres en el texto |
Versión CSS | CSS1 |
Más ejemplos
Ejemplo
Usando valores negativos:
document.getElementById("demo").style.letterSpacing = "-2px";
Ejemplo
Devuelve el espaciado entre letras de un elemento:
alert(document.getElementById("demo").style.letterSpacing);
Ejemplo
Diferencia entre la propiedad letterSpacing y la propiedad wordSpacing:
function changeLetters() {
document.getElementById("demo1").style.letterSpacing = "15px";
}
function changeWords() {
document.getElementById("demo2").style.wordSpacing = "15px";
}
páginas relacionadas
Tutorial CSS: Texto CSS
Referencia CSS: propiedad de espaciado entre letras
❮ Objeto de estilo