-3

If I try to apply this color to a HTML element:

background-color: #COFFEE; /* Should work, has 6 characters */

The color gets ignored and white (#FFF) is shown instead.

If I do:

background-color: #C0FFEE;

The color changes to something like green.

And:

background-color: #CFE;

Is probably the same color. I tested this in FF only.

PowerUser
  • 812
  • 1
  • 11
  • 32

4 Answers4

3

Hex color code consists of digits 0 to 9 and letters A to F, representing 10 to 15 in decimal mode.

So O is not a valid hex value, but 0 is.

So #COFFEE; won't work, but #C0FFEE; will.

If you want to use named colors, refer to: http://www.w3.org/TR/css3-color/ and have a look at section 4.3. Extended color keywords

E.g. Choclate which is #d2691e in hex and 210,105,30 in RGB.

Arbel
  • 30,599
  • 2
  • 28
  • 29
1

COFFEE is not a valid hexadecimal number. The sixteen hex digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F.

C0FFEE, on the other hand, is.

C016 = 19210, 192/255 = 75% red
FF16 = 25510, 255/255 = 100% green
EE16 = 23810, 238/255 = 93% blue

CFE means the same as CCFFEE, which is indeed very similar.

CC16 = 20410, 192/255 = 80% red
FF16 = 25510, 255/255 = 100% green
EE16 = 23810, 238/255 = 93% blue

If you were looking for predefined names, you'll find them here plus here.

ikegami
  • 367,544
  • 15
  • 269
  • 518
0

The color #COFFEE doesn't exist. You need to write the color code in hexadecimal after the hashtag (#), it ranges from 0 to 9 and A to F. Read more here

The color #C0FFEE (with a zero) works, but not #COFFEE (with an O).

The color #CFE is not equivalent to #C0FFEE, but to #CCFFEE.

Drown
  • 5,852
  • 1
  • 30
  • 49
0

#COFFEE

The letter O is not a valid hex value. As such, the browser will attempt to do something to accomdoate the error. That is likely going to be unpredictable.

#C0FFEE

That is a valid hex color.

#CFE;

Also a valid hex color in that it is shorthand for #ccffee

coffee

Not a valid HTML color name. However, if you are looking for a color that looks like coffee, and want to use a name value, you could try chocolate which is a valid color name.

DA.
  • 39,848
  • 49
  • 150
  • 213