Log in

View Full Version : Resolved Hex Color Question



mburt
03-02-2012, 09:23 PM
I understand the hexadecimal number set... 0-15 becomes 0-9 and A-F, and I understand that hex color codes work like #RRGGBB and the hex number correlates to the appropriate color intensity, but my question is this:

Why do these present different colors? #A60000 and #6A0000


<div style="background: #A60000; ">test</div>
<div style="background: #6A0000; ">test</div>

jscheuer1
03-03-2012, 12:51 AM
Because they're two different numbers.

The 2 digit hex code for any of the three rgb colors can be 00 to ff, or in decimal a potentially 3 digit number from 0 to 255.

The hex code is like you say rrggbb, so it's really three different 2 digit numbers in base 16. Converted to decimal rgb notation (also valid for css style color values), you would have:

#a60000 or rgb(166, 0, 0)

and:

#6a0000 or rgb(106, 0, 0)

See, two different numbers.

You can play with it yourself. Fire up Calculator. From the view menu choose 'Programmer'. Tick off hex, then enter a6. Then tick off decimal, you get 166. You can do the same with any numbers you like.

But basically a hex color value like #a60000 means - red hex a6, green hex 0, and blue hex 0.

djr33
03-03-2012, 01:02 AM
Also note that some of the confusion in this comes from the odd way that the web tends to accept invalid 3-digit hex colors like #ABC or #123, where those actually represent #AABBCC and #112233. The way the web works (or worked about 10? 15? years ago) is by expecting "web safe colors" that can be represented on all systems. So in theory you're supposed to use the same values for the two digits for each color (#RRGGBB), but in reality that's silly now. If you can use an image in your website, then there's no reason to avoid other colors in your websites. Of course if you want you can use the 3-digit shortcut, but as far as I know that was never the intent of the system (even if you don't use differing values between the two digits).

traq
03-15-2012, 04:16 AM
LMGTFY (http://lmgtfy.com/?q=hex+color+converter)

first result: http://www.yellowpipe.com/yis/tools/hex-to-rgb/color-converter.php