Some might consider this a micro-optimization, and there are many tools that can do this automatically at runtime, but there is often a need for developers to apply in source code and/or understand the output of automated tools.
A hexadecimal color is specified with: #RRGGBB
, where the RR (red), GG (green) and BB (blue) hexadecimal integers specify the components of the color.
Some common colors that most are familiar with:
CSS color name | 6 digit hex | 3 digit hex |
white |
#ffffff |
#fff |
red |
#ff0000 |
#f00 |
blue |
#0000ff |
#00f |
black |
#000000 |
#000 |
Some more complex examples:
6 digit hex | 3 digit hex |
#112233 |
#123 |
#aabbcc |
#abc |
#cccccc |
#ccc |
NOTE: while you are at these changes, this would also be a good time to change to all lower-case to improve the compression algorithms.
REFERENCES: