There are 16 colors names which are supported by all major browsers:
- white: #fff
- yellow: #ff0
- red: #ff0
- fuscia: #f0f
- silver: #c0c0c0
- gray: #808080
- olive: #808000
- purple: #800080
- maroon: #800000
- aqua: #f00
- lime: #0f0
- teal: #008080
- green: #008000
- blue: #00f
- navy: #000080
- black: #000
While there is a longer list of color names which are supported by some browsers, the 16 above are the only ones which can safely be assumed to be properly supported by all browsers. Its trivial to see that for 9 of the 16 colors it is shorter to use the color name, while in the other 7, its better to use the hex value.
Here are the color names you should remember and use over their hex values:
- red
- silver
- gray
- olive
- purple
- maroon
- teal
- green
- navy
2 comments:
Have you recommended this tip to any of the CSS minifiers, like YUI compressor?
@Zach Leatherman - Good question.
I was working on an ad hoc CSS minifier at the time. I can only assume that modern minifiers have discovered this (but I haven't verified).
I should clarify that I wouldn't recommend anyone attempt hand minification or worry about whether a color name or hex value is 1 byte shorter at this point.
Post a Comment