1. Computing

Discuss in my forum

Web Color Shorthand

Using Short Versions of Color Codes in CSS

By , About.com Guide

Once you've started using CSS layouts for your Web designs, you may notice something odd about the way the colors are defined. Rather than the standard 6-character long code after the pound sign (#cc99ff), instead you see just three characters (#c9f). This is called color shorthand and it takes advantage of the fact that the browser-safe Web palette uses triplets that are always doubled. In other words, each color triplet is made of 3 pairs of characters 0-f (base 16), and with browser-safe colors they are doubled. So, to write color shorthand, you simply remove the duplicate character.

For example:

  • White is written
    #fff
  • Black is written
    #000
  • Red is
    #f00
  • Green is
    #0f0
  • Blue is
    #00f

and so on...

©2013 About.com. All rights reserved.