Tag Archives: rgb

CSS color units

What is a color unit?

By saying CSS units some may guess this is related to the mesurement units. In fact beside the mesurment there is also a color units defined in CSS.

The most used is the #rrggbb, where the three channels red, green and blue are represented with hexadecimals, i.e. #fa03cd, or the short way #rgb. In fact #cc00cc will be the same with #c0c, but #cc02ca is not like #c0c.

Some purple #FA03CD

Actually there are other ways to set a color on an element. Such a way is to set the rgb(255,255,255), which is white. You can easyly transform the hexadecimals to decimals, it’s obvious that xFF is 255 in decimals.

There are five ways to set up a color with CSS

In general there are five ways to set up color with CSS:

#rrggbb ( for red, green and blue as mentioned – #FF00FA )

#rgb ( short way to say #rrggbb – #CC3 )

rgb( x, y, z ) – ( where x, y and z are numbers between 0 and 255 – rgb( 255, 255, 255) )

rgb( x, y, z ) – ( where x, y and z are percents between 0 and 100 – rgb( 100%, 20%, 23%) )

The Windows palette

There is a fift way to set a color on a element with CSS, with predefined colors corresponding to the MS Windows VGA palette, and they are:

aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow