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
EasyYou 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:
- Write a CSS rule that targets the
<h1>element. Set thecolortopurple. - Write a CSS rule that targets the
<p>element. Set thecolortoyellow.
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>This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Styling with CSS
4Text Fundamentals
Text ColorFont FamilyFont SizeFont WeightText AlignmentText DecorationRecap Challenge #1Recap Challenge #25 Colors and Backgrounds
Background ColorHEX ColorsRGB ColorsTransparency with RGBARecap Challenge #1