Jump to content

CSS: Understanding HTML Color Codes

- - - - -

  • Please log in to reply
5 replies to this topic

#1
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
#00FF00
Whaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa?
That is the color code for green, looks difficult? Well its simple.
Lets take our three primary colors:
Red, green and blue.
These colors form HTML color codes quite simply:
RR:GG:BB
Now we use hexadecimal numbers to do this, hexadecimal goes up to 9 then uses a,b,c,d,e and f to represent 10,11,12,13,14 and 15.
My example simply says use no red or blue with maximum (15 or F) green.

You might have noticed we use two hexadecimal values for each color, takes the browser the first value (of each color) and multiplies it by 16 and then adds the second value to the result to get a number out of 255. For those of you who have opened up the color mixer in most image programs (including MS Paint, some programs might put this under the 'advanced' tab) 255 will seem familiar. So now look what are color code comes to:
#00FF00
0,0,15,15,0,0
Red: (0X0) + 0 = 0
Green: (15X16) + 15 = 255
Blue: (0X0) + 0 = 0

Red: 0
Green: 255
Blue: 0

Notes

Just remember that 0 of each color makes black (#000000), it will lighten as you increase each color so a full amount of each color will make white while 8 of each color (#888888) will make a grey (half white half black) color.

HTML color codes should start with a #.

Oh and colors that use three sets of two hexadecimals (that are the same eg, FF0099 or FFFF00 and 668888) are called 'true colors'.

Edited by bbqroast, 27 July 2011 - 09:24 PM.

Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#2
op2rules

op2rules

    Newbie

  • Members
  • Pip
  • 5 posts
Green: (15X15) + 15 = 255

You mean 15*16

Just pointin er out

#3
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
Thanks for pointing out :)
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#4
stevie754

stevie754

    Programmer

  • Members
  • PipPipPipPip
  • 110 posts
A good simple easy to understand explanation :) +rep

#5
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
No problem, I kinda figured this out although the 6 hexadecimals (instead of 3) did confuse me. Writing this taught me something to.

Ahhhh I forgot something.
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#6
vaironl

vaironl

    Programmer

  • Members
  • PipPipPipPip
  • 117 posts
Thanks for this quick tut.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users