Menu
Coddy logo textTech

Text Color

Part of the Styling with CSS section of Coddy's HTML journey — lesson 17 of 76.

In CSS, the color property is used to set the color of the text inside an element. You can apply different color values to text to enhance the appearance of your webpage.

selector {
    color: value;
}

For example:

h3{
  color: purple;
}
challenge icon

Challenge

Easy

You are given an HTML document with a heading (<h1>) and a paragraph (<p>). Your task is to use the color property to style these elements. Follow the steps below:

  1. Write a CSS rule that targets the <h1> element. Set the color to purple.
  2. Write a CSS rule that targets the <p> element. Set the color to yellow.

Cheat sheet

The color property sets the color of text inside an element:

selector {
    color: value;
}

Example:

h3 {
    color: purple;
}

Try it yourself

<html>
<head>
    <title>Text Color</title>
    <style>
        /* Write CSS rules here */
    </style>
</head>
<body>
    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
</body>
</html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Styling with CSS