Sombra de texto CSS


Tabla de contenido

    Mostrar tabla de contenidos


Sombra de texto

La propiedad text-shadow agrega sombra al texto.

En su uso más simple, solo especificas la sombra horizontal (2px) y la sombra vertical (2px):

Text shadow effect!

Ejemplo

  h1
{
  text-shadow: 2px 2px;
}

Pruébelo usted mismo →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 2px 2px;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>


Luego, agrega un color (rojo) a la sombra:

Text shadow effect!

Ejemplo

  h1
{
  text-shadow: 2px 2px red;
}

Pruébelo usted mismo →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 2px 2px red;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>


Luego, agrega un efecto de desenfoque (5px) a la sombra:

Text shadow effect!

Ejemplo

   h1
{
  text-shadow: 2px 2px 5px red;
}

Pruébelo usted mismo →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 2px 2px 5px red;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>



Más ejemplos de sombras de texto

Ejemplo 1

Sombra de texto sobre un texto blanco:

h1 {
  color: white;
  text-shadow: 2px 2px 4px #000000;
}

Pruébelo usted mismo →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  color: white;
  text-shadow: 2px 2px 4px #000000;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>


Ejemplo 2

Sombra de texto con brillo de neón rojo:

h1 {
  text-shadow: 0 0 3px #ff0000;
}

Pruébelo usted mismo →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 0 0 3px #FF0000;
}
</style>
</head>
<body>

<h1>Text-shadow with red neon glow!</h1>

</body>
</html>


Ejemplo 3

Sombra de texto con brillo de neón rojo y azul:

h1 {
  text-shadow: 0 0 3px #ff0000, 0 0 5px #0000ff;
}

Pruébelo usted mismo →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;
}
</style>
</head>
<body>

<h1>Text-shadow with red and blue neon glow!</h1>

</body>
</html>


Ejemplo 4

h1 {
  color: white;
  text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 
  0 5px darkblue;
}

Pruébelo usted mismo →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  color: white;
  text-shadow: 1px 1px 2px black, 0 0 25px blue, 0 0 5px darkblue;
}
</style>
</head>
<body>

<h1>Text-shadow effect!</h1>

</body>
</html>


Consejo: Vaya a nuestro capítulo Fuentes CSS para aprender cómo cambiar las fuentes, el tamaño del texto y el estilo de un texto.

Consejo: Vaya a nuestro capítulo Efectos de texto CSS para conocer los diferentes efectos de texto.




La propiedad de sombra de texto CSS

text-shadow

Especifica el efecto de sombra agregado al texto.