CSS Text Color and Decoration

Learn how to use CSS properties to control the color, style, and visual appearance of your text.

Dressing Words: CSS Text Styling

With CSS, you can bring your text to life. Properties like `color`, `text-decoration`, and `text-shadow` allow you to change the appearance of your words in a creative way.

The 'color' Property

The color property sets the color of the text. It's applied directly to the element you want to style. For example: p { color: blue; }.

The 'text-decoration' Property

The text-decoration property is used to add or remove lines from text. Common values include underline, overline, and line-through. Using none is common to remove the default underline from links.

The 'text-shadow' Property

The text-shadow property adds a shadow effect. It takes values for horizontal offset, vertical offset, blur radius, and color. For example: h1 { text-shadow: 2px 2px 4px gray; }.

Practice Zone


Interactive Test 1: Drag & Drop

Arrastra en el orden correspondiente.


Arrastra las opciones:

color: red;
text-decoration: underline;
text-shadow: 2px 2px 4px gray;

Completa el código:

Defines the color of the text.______
Adds or removes text decorations.______
Applies a shadow to the text.______

Interactive Test 2: Fill in the Blanks

Rellena los huecos en cada casilla.

p { color: ; text-decoration: ; text-shadow: ;}

Practice Example: Code Editor

Write a CSS rule that styles a paragraph with `red` text color, an `underline`, and a `gray` text shadow.

Enunciado:

* Escribe el código a continuación. Los caracteres correctos se mostrarán en verde y los incorrectos en rojo.

<h1>Estilos de Fuente</h1> <p class="font-style">Este es un párrafo con una fuente especial y un tamaño grande.</p> <style> .font-style { font-family: 'Arial', sans-serif; font-size: 20px; font-weight: bold; line-height: 1.5; color: #333333; } </style>

Knowledge Check

Which of the following is a CSS property for applying color to text?