CSS color
Anonymous contributor
Published Jul 7, 2021Updated Jan 6, 2024
Contribute to Docs
To set color property values for an element. color sets the color of an element’s textual and decorative parts and text.
Syntax
color: value;
The value of the color property can be any of the following:
- Name of the color (e.g.,
aqua,khaki,red) - RGB (red, green, and blue) colors (e.g.,
rgb(249, 2, 171)) - Hexadecimal colors (e.g.,
#ff0000)
Example
The h1 tag is set to be orange in color, and the p tag is set as pink in color. The background color, black/#000000/rgb(0,0,0), is only set for context:
body {background-color: black;}h1 {color: orange;}p {color: pink;}
body {background-color: #000000;}h1 {color: #ffa500;}p {color: #ffc0cb;}
body {background-color: rgb(0, 0, 0);}h1 {color: rgb(255, 165, 0);}p {color: rgb(255, 192, 203);}
Three examples were given in the example block above, each of them would yield or translate to the same output:

Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn CSS on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- A full-stack engineer can get a project done from start to finish, back-end to front-end.
- Includes 51 Courses
- With Professional Certification
- Beginner Friendly.150 hours