Style textDecorationPropiedad
Objeto Style
Definición y uso
La propiedad textDecoration establece o devuelve una o más decoraciones de texto.
Consejo:Para especificar más de un tipo de decoración para un elemento, especifique una lista separada por espacios.
Sintaxis
Establecer la propiedad textDecoration:
Object.style.textDecoration="none|underline|overline|line-through|blink|inherit"
Devolver la propiedad textDecoration:
Object.style.textDecoration
| Valor | Descripción |
|---|---|
| none | Por defecto. Define texto estándar. |
| underline | Define una línea debajo del texto. |
| overline | Define una línea sobre el texto. |
| line-through | Define una línea a través del texto. |
| inherit | El valor de la propiedad textDecoration se hereda del elemento padre. |
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten la propiedad textDecoration.
Nota:IE7 y versiones anteriores no admiten el valor "inherit". IE8 solo admite "inherit" si se especifica !DOCTYPE. IE9 admite "inherit".
Ejemplo
Ejemplo
Decorar texto:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Ejemplo(example.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.textDecoration="underline overline";
}
</script>
</head>
<body>
<p id="p1">Este es algo de texto.</p>
<br>
<button type="button" onclick="displayResult()">Decorar texto</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Ejemplo(example.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.textDecoration="underline overline";
}
</script>
</head>
<body>
<p id="p1">Este es algo de texto.</p>
<br>
<button type="button" onclick="displayResult()">Decorar texto</button>
</body>
</html>
Pruébalo »
Objeto Style Otras extensiones