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 Use Color in CSS

Hi, I am starting the section on Hexadecimal colors. ? Is there a logic path for the difference between #3b and #b3?

The system is obviously very logically laid out. 00 black ff white... etc but for the values in-between what is the difference in a red shift from #cf to #fc? Do the places they hold in the paired set have a value of its own?

4 Answers

Andrew Shook
Andrew Shook
31,709 Points

Hexadecimal color are just another way of writing the rgb color value. With rgb a color can range from 0 to 255, meaning there are 256 possible values for either red green or blue. With hexadecimals, a value can range from 0 - 9 and then a-f, where a = 10 and f = 15. This means the a single hexadecimal can have up to 16 possible values. However in colors, hexadecimals are alway used in pairs, because 16 X 16 = 256. The way the hexadecimals are pair is that the first character represents how many time rgb number can be divided by 16 and the second character represents the remainder left over after the division. For example, is a color has an rgb value of 38, 120, and 75 then its hex value would be #26784b. So how did I get that number? I took 38 and divided it by 16 and got 2.375. Since I know that 16X2=32 i subtracted 32 from 38 and got the 6. So the hex of 38 is #26. So #cf is not equal to #fc, because #cf = 207 and #fc = 252.

Thanks for the explanation. In reality I imagine that most people just pick a pretty color and do not worry about why the code is what it is, but it helps to understand the logic behind it.

I imagine that I will be one of those "most people" ha

Cheers!

James that really helped, The first in the 2 digit code is the primary and the second is the refinement. Got it! Thanks for sharing that link!

Cheers!