Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS How to Make a Website Customizing Colors and Fonts Review: Customizing Colors and Fonts

Martina Vonkomerova
Martina Vonkomerova
7,790 Points

Hexadecimal code to colors in CSS

Can somebody explain how to write hexadecimal color code in CSS?

3 Answers

Ryan Field
PLUS
Ryan Field
Courses Plus Student 21,242 Points

Hexadecimal colours are made up of three groups of two numbers, all six of which range from 0-F (that is, 0 1 2 3 4 5 6 7 8 9 A B C D E F for essentially 16 digits). The first two numbers make up the red value, the middle two make up the green value, and the last two make up the blue value. As such, a value of #FF0000 would be pure red and #00FF00 would be pure green.

That said, you don't have to memorize how to make hexadecimal values for colours. There are plenty of online tools (and even tools like Photoshop) where you can pick a colour and it will provide you with the hexadecimal value, so don't worry! :)

It is very easy to use hexadecimal color code's in css, for example:

    p {
      color: #000;
      background-color: #f1f1f1;
    }