How do you change the font color using CSS?
In CSS, we use the color property to set the foreground color of the text content for an element.
The code snippet below shows the syntax of using the color property to set the color of the <h1> element.
The value of the color property can be specified in three ways:
- Using
RGB valuese.g. rgb(250,0,0), rgb(0,250,0), etc. - Using a
Hexadecimal(HEX) valuee.g. #FFFFFF, #000000, etc. - Using a valid
color namee.g. “white”, “red”, “black”, “blue”, etc.
In the code snippet above, a valid color name is used to set the color for <h1>. In case of <h3>, rgb values are used and a HEX value is used to set the color for the <p> tag.
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved