5

Possible Duplicate:
Using 3-digit color codes rather than 6-digit color codes in CSS

I was checking out the CSS of the new YouTube website. There are many examples of usages of 6-digit hex color codes when 3 are sufficient, eg:

  • color:#990000
  • color:#550000
  • color:#000000
  • color:#005500

I always prefer 3 characters in that case. Perhaps YouTube feels this makes it clearer and shortening this to 3 characters is not worth the minimal savings. That is fine. I am just wondering if there is not an additional technical benefit in using 6 characters - for instance, lack of compatibility of 3 chars with certain old browsers. Any idea?

Community
  • 1
  • 1
  • Is your question restricted to only cases where 3-digit codes can **always** be used in place of 6 digits (i.e. it doesn't matter how many more colors you get to choose with 6)? – BoltClock Dec 03 '11 at 21:06
  • @BoltClock Yes, correct. My question is about any technical drawback that might exist when you use a 6-char code vs 3-char code (say #000000 vs #000). –  Dec 03 '11 at 21:08
  • Once the stream is compressed, there is really no point to worry about "wasted space" with expanded 6-digit codes. In fact, being *consistent* with using the 6-digit form *might* even yield (ever so *insignificantly*) *better* compression results due to the increase of pattern length. –  Dec 03 '11 at 21:17
  • 1
    Then there is no technical benefit; the one technical drawback, however, well, has just been mentioned and then immediately downplayed (for a good reason of course) many times over... :) – BoltClock Dec 03 '11 at 21:19

2 Answers2

4

There is no significant difference.

Yes, they could shave a few bytes off their network payload by shortening #990000 to #900 and I admit that I'm surprised that their CSS minifier didn't do that.

Then again, if they are sending it over the network using compression (which they probably are), then compression will totally take care of those three bytes.

Hence, no significant difference.

Trott
  • 66,479
  • 23
  • 173
  • 212
0

Strictly speaking, there is in fact a small technical penalty, since you are sending 3 extra characters over the network...

The Nail
  • 8,355
  • 2
  • 35
  • 48