1. Home
  2. Computing & Technology
  3. Web Design / HTML

Web Color Shorthand
Using Short Versions of Color Codes in CSS

By Jennifer Kyrnin, About.com

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...

Explore Web Design / HTML
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. Web Design
  5. Principles of Web Design
  6. Color
  7. Web Color Shorthand - Using Short Versions of Color Codes in CSS>

©2009 About.com, a part of The New York Times Company.

All rights reserved.