To change the text color with CSS, you should use the color
CSS property. The value for it can be provided using 3 main options:
- a name of the color — “red”, “green”, “blue”
- a HEX code that starts with the hashtag — “#00FF00”, “#121212”
- an RGB code that looks like this — “rgb(125, 20, 255)”
Let’s use all three options to write CSS that changes the color of the headers h1
, h2
, and h3
.
h1 {
color: gold;
}
h2 {
color: #008000;
}
h3 {
color: rgb(128, 0, 128);
}
As a result h1
header will turn gold
, h2
header will become green
and the h3
header will be purple.
Get a full list of 140 colors that you can use in your HTML and CSS or learn Full-Stack JavaScript from scratch.