3 Digits or 6 Digits in hex colors?

Hi everyone,

I have some questions about the hex colors.

1.Assume that we have a 6 digits number which can be shortened into 3 digits. In what kind of situation, we better use the 3 digits instead of 6 digits?

Is 3 digits used for saving bytes? But in this case, will its maintainability reduce?
Is it always better to use 6 digits than 3 digits? (make the result more exact and easy to make small changes in the future?)

  1. I know that a 6 digits number whose number pairs are the same characters can be shortened into 3 digits one. But I still don’t understand why we can omit the repetitive digits.

Thank you.


The only time you shorten a hexadecimal color is when the two characters in all three pairs of digits are the same:


To my knowledge shortening it to three characters is just a shorthand way of writing it, and the browser still reads it as a six digit value. As such there is not much of a difference asides from improved readability, easier typing, and a three byte reduction in the the CSS file.