HTML and CSS Reference
InDepth Information
Name
#rrggbb
#rgb
rgb(r,g,b)
Black
#000000
#000
rgb(0,0,0)
Blue
#0000ff
#00f
rgb(0,0,255)
Red
#ff0000
#f00
rgb(255,0,0)
Yellow
#ffff00
#ff0
rgb(255,255,0)
Green
#008000

rgb(0,128,0)
Teal
#008080

rgb(0,128,128)
Silver
#c0c0c0

rgb(192.192,192)
Gray
#808080

rgb(128,128,128)
White
#ffffff
#fff
rgb(255,255,255)
The middle two columns use hexadecimal notation. These are numbers
in base 16: after getting to 9, the next number is A, then B, and so on,
up to
F
. The hexadecimal value FF is equivalent to 255 in decimal. If
the two numerals for each of the red, green, and blue values are the
same, then you can use the shorthand notation in the third column.
Color has its own property. The following example sets the foreground
(text) color of an element and its descendants to blue:
color: #00f;
Lengths are less complicated than colors: they consist of a number fol
lowed by a unit. The most common units are shown in the next table.
Unit
Measures by
Description
px
Pixels
Length in pixel units. The actual size is determined by monitor resolution.
pt
Points
A measure from typography, equivalent to 1/72 of an inch.
cm
Centimeters
Absolute length in centimeters. If you're not in a metric country, you can
also use
in
for inches.
em
Ems
Size of the capital
M
in the current font.
%
Percentage
Length as a proportion of the size of the element's parent.