HTML file being edited by vim.

Colors in HTML with CSS

Control Colors with Cascading Style Sheets (CSS)

Obama Is Black!  RGB = #000000!

Colors can be set by name, but this relies on browsers supporting the same set of color names. And it requires you to know the specific names, which is no big deal if you only use a few bright colors but it is a hassle if you want subtle colors on your web pages.

It's just as easy and far safer to specify colors by hexadecimal (base 16) descriptions. #000000 and #000 are black, #FF0000 and #F00 are red, #FFFF00 and #FF0 are yellow, #FF00FF and #F0F are magenta, and so on.

Find the operating system color definitions

Let's build a table using the standard X graphical display system colors. Linux, OpenBSD and Solaris store the standard X11 color definitions in slightly different places, but we can find it easily enough. Look for a file named rgb.txt somewhere under /usr.

Linux% find /usr -name rgb.txt
/usr/share/X11/rgb.txt

OpenBSD% find /usr -name rgb.txt
/usr/X11R6/share/X11/rgb.txt

Solaris% find /usr -name rgb.txt
/usr/X11/lib/X11/rgb.txt

Convert rgb.txt to an HTML table

Now we just need a simple awk program to turn that data into HTML:

#!/usr/bin/awk -f

BEGIN {	printf("<table border=\"1\" style=\"font-family: Courier, monospace;\">\n");
	printf("<tr><td style=\"text-align: center;\">Name</td>");
	printf("<td style=\"text-align: center;\">R G B</td>");
	printf("<td style=\"text-align: center;\">Color</td>\n");
}

/* Only non-grey colors */
$1 != $2 || $2 != $3 {
	printf("<tr><td>");
	for (i = 4; i <= NF; i++) {
		printf("%s ", $i);
	}
	printf("<td>%02x %02x %02x</td>", $1, $2, $3);
	printf("<td style=\"background: #%02x%02x%02x;\"> </td>", $1, $2, $3);
	printf("</tr>\n");
}

END {	printf("</table>\n"); }

HTML Colors

Here is the result of running that awk script on the local rbg.txt file:

NameR G BColor
snow ff fa fa
ghost white f8 f8 ff
GhostWhite f8 f8 ff
floral white ff fa f0
FloralWhite ff fa f0
old lace fd f5 e6
OldLace fd f5 e6
linen fa f0 e6
antique white fa eb d7
AntiqueWhite fa eb d7
papaya whip ff ef d5
PapayaWhip ff ef d5
blanched almond ff eb cd
BlanchedAlmond ff eb cd
bisque ff e4 c4
peach puff ff da b9
PeachPuff ff da b9
navajo white ff de ad
NavajoWhite ff de ad
moccasin ff e4 b5
cornsilk ff f8 dc
ivory ff ff f0
lemon chiffon ff fa cd
LemonChiffon ff fa cd
seashell ff f5 ee
honeydew f0 ff f0
mint cream f5 ff fa
MintCream f5 ff fa
azure f0 ff ff
alice blue f0 f8 ff
AliceBlue f0 f8 ff
lavender e6 e6 fa
lavender blush ff f0 f5
LavenderBlush ff f0 f5
misty rose ff e4 e1
MistyRose ff e4 e1
dark slate gray 2f 4f 4f
DarkSlateGray 2f 4f 4f
dark slate grey 2f 4f 4f
DarkSlateGrey 2f 4f 4f
slate gray 70 80 90
SlateGray 70 80 90
slate grey 70 80 90
SlateGrey 70 80 90
light slate gray 77 88 99
LightSlateGray 77 88 99
light slate grey 77 88 99
LightSlateGrey 77 88 99
midnight blue 19 19 70
MidnightBlue 19 19 70
navy 00 00 80
navy blue 00 00 80
NavyBlue 00 00 80
cornflower blue 64 95 ed
CornflowerBlue 64 95 ed
dark slate blue 48 3d 8b
DarkSlateBlue 48 3d 8b
slate blue 6a 5a cd
SlateBlue 6a 5a cd
medium slate blue 7b 68 ee
MediumSlateBlue 7b 68 ee
light slate blue 84 70 ff
LightSlateBlue 84 70 ff
medium blue 00 00 cd
MediumBlue 00 00 cd
royal blue 41 69 e1
RoyalBlue 41 69 e1
blue 00 00 ff
dodger blue 1e 90 ff
DodgerBlue 1e 90 ff
deep sky blue 00 bf ff
DeepSkyBlue 00 bf ff
sky blue 87 ce eb
SkyBlue 87 ce eb
light sky blue 87 ce fa
LightSkyBlue 87 ce fa
steel blue 46 82 b4
SteelBlue 46 82 b4
light steel blue b0 c4 de
LightSteelBlue b0 c4 de
light blue ad d8 e6
LightBlue ad d8 e6
powder blue b0 e0 e6
PowderBlue b0 e0 e6
pale turquoise af ee ee
PaleTurquoise af ee ee
dark turquoise 00 ce d1
DarkTurquoise 00 ce d1
medium turquoise 48 d1 cc
MediumTurquoise 48 d1 cc
turquoise 40 e0 d0
cyan 00 ff ff
light cyan e0 ff ff
LightCyan e0 ff ff
cadet blue 5f 9e a0
CadetBlue 5f 9e a0
medium aquamarine 66 cd aa
MediumAquamarine 66 cd aa
aquamarine 7f ff d4
dark green 00 64 00
DarkGreen 00 64 00
dark olive green 55 6b 2f
DarkOliveGreen 55 6b 2f
dark sea green 8f bc 8f
DarkSeaGreen 8f bc 8f
sea green 2e 8b 57
SeaGreen 2e 8b 57
medium sea green 3c b3 71
MediumSeaGreen 3c b3 71
light sea green 20 b2 aa
LightSeaGreen 20 b2 aa
pale green 98 fb 98
PaleGreen 98 fb 98
spring green 00 ff 7f
SpringGreen 00 ff 7f
lawn green 7c fc 00
LawnGreen 7c fc 00
green 00 ff 00
chartreuse 7f ff 00
medium spring green 00 fa 9a
MediumSpringGreen 00 fa 9a
green yellow ad ff 2f
GreenYellow ad ff 2f
lime green 32 cd 32
LimeGreen 32 cd 32
yellow green 9a cd 32
YellowGreen 9a cd 32
forest green 22 8b 22
ForestGreen 22 8b 22
olive drab 6b 8e 23
OliveDrab 6b 8e 23
dark khaki bd b7 6b
DarkKhaki bd b7 6b
khaki f0 e6 8c
pale goldenrod ee e8 aa
PaleGoldenrod ee e8 aa
light goldenrod yellow fa fa d2
LightGoldenrodYellow fa fa d2
light yellow ff ff e0
LightYellow ff ff e0
yellow ff ff 00
gold ff d7 00
light goldenrod ee dd 82
LightGoldenrod ee dd 82
goldenrod da a5 20
dark goldenrod b8 86 0b
DarkGoldenrod b8 86 0b
rosy brown bc 8f 8f
RosyBrown bc 8f 8f
indian red cd 5c 5c
IndianRed cd 5c 5c
saddle brown 8b 45 13
SaddleBrown 8b 45 13
sienna a0 52 2d
peru cd 85 3f
burlywood de b8 87
beige f5 f5 dc
wheat f5 de b3
sandy brown f4 a4 60
SandyBrown f4 a4 60
tan d2 b4 8c
chocolate d2 69 1e
firebrick b2 22 22
brown a5 2a 2a
dark salmon e9 96 7a
DarkSalmon e9 96 7a
salmon fa 80 72
light salmon ff a0 7a
LightSalmon ff a0 7a
orange ff a5 00
dark orange ff 8c 00
DarkOrange ff 8c 00
coral ff 7f 50
light coral f0 80 80
LightCoral f0 80 80
tomato ff 63 47
orange red ff 45 00
OrangeRed ff 45 00
red ff 00 00
hot pink ff 69 b4
HotPink ff 69 b4
deep pink ff 14 93
DeepPink ff 14 93
pink ff c0 cb
light pink ff b6 c1
LightPink ff b6 c1
pale violet red db 70 93
PaleVioletRed db 70 93
maroon b0 30 60
medium violet red c7 15 85
MediumVioletRed c7 15 85
violet red d0 20 90
VioletRed d0 20 90
magenta ff 00 ff
violet ee 82 ee
plum dd a0 dd
orchid da 70 d6
medium orchid ba 55 d3
MediumOrchid ba 55 d3
dark orchid 99 32 cc
DarkOrchid 99 32 cc
dark violet 94 00 d3
DarkViolet 94 00 d3
blue violet 8a 2b e2
BlueViolet 8a 2b e2
purple a0 20 f0
medium purple 93 70 db
MediumPurple 93 70 db
thistle d8 bf d8
snow1 ff fa fa
snow2 ee e9 e9
snow3 cd c9 c9
snow4 8b 89 89
seashell1 ff f5 ee
seashell2 ee e5 de
seashell3 cd c5 bf
seashell4 8b 86 82
AntiqueWhite1 ff ef db
AntiqueWhite2 ee df cc
AntiqueWhite3 cd c0 b0
AntiqueWhite4 8b 83 78
bisque1 ff e4 c4
bisque2 ee d5 b7
bisque3 cd b7 9e
bisque4 8b 7d 6b
PeachPuff1 ff da b9
PeachPuff2 ee cb ad
PeachPuff3 cd af 95
PeachPuff4 8b 77 65
NavajoWhite1 ff de ad
NavajoWhite2 ee cf a1
NavajoWhite3 cd b3 8b
NavajoWhite4 8b 79 5e
LemonChiffon1 ff fa cd
LemonChiffon2 ee e9 bf
LemonChiffon3 cd c9 a5
LemonChiffon4 8b 89 70
cornsilk1 ff f8 dc
cornsilk2 ee e8 cd
cornsilk3 cd c8 b1
cornsilk4 8b 88 78
ivory1 ff ff f0
ivory2 ee ee e0
ivory3 cd cd c1
ivory4 8b 8b 83
honeydew1 f0 ff f0
honeydew2 e0 ee e0
honeydew3 c1 cd c1
honeydew4 83 8b 83
LavenderBlush1 ff f0 f5
LavenderBlush2 ee e0 e5
LavenderBlush3 cd c1 c5
LavenderBlush4 8b 83 86
MistyRose1 ff e4 e1
MistyRose2 ee d5 d2
MistyRose3 cd b7 b5
MistyRose4 8b 7d 7b
azure1 f0 ff ff
azure2 e0 ee ee
azure3 c1 cd cd
azure4 83 8b 8b
SlateBlue1 83 6f ff
SlateBlue2 7a 67 ee
SlateBlue3 69 59 cd
SlateBlue4 47 3c 8b
RoyalBlue1 48 76 ff
RoyalBlue2 43 6e ee
RoyalBlue3 3a 5f cd
RoyalBlue4 27 40 8b
blue1 00 00 ff
blue2 00 00 ee
blue3 00 00 cd
blue4 00 00 8b
DodgerBlue1 1e 90 ff
DodgerBlue2 1c 86 ee
DodgerBlue3 18 74 cd
DodgerBlue4 10 4e 8b
SteelBlue1 63 b8 ff
SteelBlue2 5c ac ee
SteelBlue3 4f 94 cd
SteelBlue4 36 64 8b
DeepSkyBlue1 00 bf ff
DeepSkyBlue2 00 b2 ee
DeepSkyBlue3 00 9a cd
DeepSkyBlue4 00 68 8b
SkyBlue1 87 ce ff
SkyBlue2 7e c0 ee
SkyBlue3 6c a6 cd
SkyBlue4 4a 70 8b
LightSkyBlue1 b0 e2 ff
LightSkyBlue2 a4 d3 ee
LightSkyBlue3 8d b6 cd
LightSkyBlue4 60 7b 8b
SlateGray1 c6 e2 ff
SlateGray2 b9 d3 ee
SlateGray3 9f b6 cd
SlateGray4 6c 7b 8b
LightSteelBlue1 ca e1 ff
LightSteelBlue2 bc d2 ee
LightSteelBlue3 a2 b5 cd
LightSteelBlue4 6e 7b 8b
LightBlue1 bf ef ff
LightBlue2 b2 df ee
LightBlue3 9a c0 cd
LightBlue4 68 83 8b
LightCyan1 e0 ff ff
LightCyan2 d1 ee ee
LightCyan3 b4 cd cd
LightCyan4 7a 8b 8b
PaleTurquoise1 bb ff ff
PaleTurquoise2 ae ee ee
PaleTurquoise3 96 cd cd
PaleTurquoise4 66 8b 8b
CadetBlue1 98 f5 ff
CadetBlue2 8e e5 ee
CadetBlue3 7a c5 cd
CadetBlue4 53 86 8b
turquoise1 00 f5 ff
turquoise2 00 e5 ee
turquoise3 00 c5 cd
turquoise4 00 86 8b
cyan1 00 ff ff
cyan2 00 ee ee
cyan3 00 cd cd
cyan4 00 8b 8b
DarkSlateGray1 97 ff ff
DarkSlateGray2 8d ee ee
DarkSlateGray3 79 cd cd
DarkSlateGray4 52 8b 8b
aquamarine1 7f ff d4
aquamarine2 76 ee c6
aquamarine3 66 cd aa
aquamarine4 45 8b 74
DarkSeaGreen1 c1 ff c1
DarkSeaGreen2 b4 ee b4
DarkSeaGreen3 9b cd 9b
DarkSeaGreen4 69 8b 69
SeaGreen1 54 ff 9f
SeaGreen2 4e ee 94
SeaGreen3 43 cd 80
SeaGreen4 2e 8b 57
PaleGreen1 9a ff 9a
PaleGreen2 90 ee 90
PaleGreen3 7c cd 7c
PaleGreen4 54 8b 54
SpringGreen1 00 ff 7f
SpringGreen2 00 ee 76
SpringGreen3 00 cd 66
SpringGreen4 00 8b 45
green1 00 ff 00
green2 00 ee 00
green3 00 cd 00
green4 00 8b 00
chartreuse1 7f ff 00
chartreuse2 76 ee 00
chartreuse3 66 cd 00
chartreuse4 45 8b 00
OliveDrab1 c0 ff 3e
OliveDrab2 b3 ee 3a
OliveDrab3 9a cd 32
OliveDrab4 69 8b 22
DarkOliveGreen1 ca ff 70
DarkOliveGreen2 bc ee 68
DarkOliveGreen3 a2 cd 5a
DarkOliveGreen4 6e 8b 3d
khaki1 ff f6 8f
khaki2 ee e6 85
khaki3 cd c6 73
khaki4 8b 86 4e
LightGoldenrod1 ff ec 8b
LightGoldenrod2 ee dc 82
LightGoldenrod3 cd be 70
LightGoldenrod4 8b 81 4c
LightYellow1 ff ff e0
LightYellow2 ee ee d1
LightYellow3 cd cd b4
LightYellow4 8b 8b 7a
yellow1 ff ff 00
yellow2 ee ee 00
yellow3 cd cd 00
yellow4 8b 8b 00
gold1 ff d7 00
gold2 ee c9 00
gold3 cd ad 00
gold4 8b 75 00
goldenrod1 ff c1 25
goldenrod2 ee b4 22
goldenrod3 cd 9b 1d
goldenrod4 8b 69 14
DarkGoldenrod1 ff b9 0f
DarkGoldenrod2 ee ad 0e
DarkGoldenrod3 cd 95 0c
DarkGoldenrod4 8b 65 08
RosyBrown1 ff c1 c1
RosyBrown2 ee b4 b4
RosyBrown3 cd 9b 9b
RosyBrown4 8b 69 69
IndianRed1 ff 6a 6a
IndianRed2 ee 63 63
IndianRed3 cd 55 55
IndianRed4 8b 3a 3a
sienna1 ff 82 47
sienna2 ee 79 42
sienna3 cd 68 39
sienna4 8b 47 26
burlywood1 ff d3 9b
burlywood2 ee c5 91
burlywood3 cd aa 7d
burlywood4 8b 73 55
wheat1 ff e7 ba
wheat2 ee d8 ae
wheat3 cd ba 96
wheat4 8b 7e 66
tan1 ff a5 4f
tan2 ee 9a 49
tan3 cd 85 3f
tan4 8b 5a 2b
chocolate1 ff 7f 24
chocolate2 ee 76 21
chocolate3 cd 66 1d
chocolate4 8b 45 13
firebrick1 ff 30 30
firebrick2 ee 2c 2c
firebrick3 cd 26 26
firebrick4 8b 1a 1a
brown1 ff 40 40
brown2 ee 3b 3b
brown3 cd 33 33
brown4 8b 23 23
salmon1 ff 8c 69
salmon2 ee 82 62
salmon3 cd 70 54
salmon4 8b 4c 39
LightSalmon1 ff a0 7a
LightSalmon2 ee 95 72
LightSalmon3 cd 81 62
LightSalmon4 8b 57 42
orange1 ff a5 00
orange2 ee 9a 00
orange3 cd 85 00
orange4 8b 5a 00
DarkOrange1 ff 7f 00
DarkOrange2 ee 76 00
DarkOrange3 cd 66 00
DarkOrange4 8b 45 00
coral1 ff 72 56
coral2 ee 6a 50
coral3 cd 5b 45
coral4 8b 3e 2f
tomato1 ff 63 47
tomato2 ee 5c 42
tomato3 cd 4f 39
tomato4 8b 36 26
OrangeRed1 ff 45 00
OrangeRed2 ee 40 00
OrangeRed3 cd 37 00
OrangeRed4 8b 25 00
red1 ff 00 00
red2 ee 00 00
red3 cd 00 00
red4 8b 00 00
DeepPink1 ff 14 93
DeepPink2 ee 12 89
DeepPink3 cd 10 76
DeepPink4 8b 0a 50
HotPink1 ff 6e b4
HotPink2 ee 6a a7
HotPink3 cd 60 90
HotPink4 8b 3a 62
pink1 ff b5 c5
pink2 ee a9 b8
pink3 cd 91 9e
pink4 8b 63 6c
LightPink1 ff ae b9
LightPink2 ee a2 ad
LightPink3 cd 8c 95
LightPink4 8b 5f 65
PaleVioletRed1 ff 82 ab
PaleVioletRed2 ee 79 9f
PaleVioletRed3 cd 68 89
PaleVioletRed4 8b 47 5d
maroon1 ff 34 b3
maroon2 ee 30 a7
maroon3 cd 29 90
maroon4 8b 1c 62
VioletRed1 ff 3e 96
VioletRed2 ee 3a 8c
VioletRed3 cd 32 78
VioletRed4 8b 22 52
magenta1 ff 00 ff
magenta2 ee 00 ee
magenta3 cd 00 cd
magenta4 8b 00 8b
orchid1 ff 83 fa
orchid2 ee 7a e9
orchid3 cd 69 c9
orchid4 8b 47 89
plum1 ff bb ff
plum2 ee ae ee
plum3 cd 96 cd
plum4 8b 66 8b
MediumOrchid1 e0 66 ff
MediumOrchid2 d1 5f ee
MediumOrchid3 b4 52 cd
MediumOrchid4 7a 37 8b
DarkOrchid1 bf 3e ff
DarkOrchid2 b2 3a ee
DarkOrchid3 9a 32 cd
DarkOrchid4 68 22 8b
purple1 9b 30 ff
purple2 91 2c ee
purple3 7d 26 cd
purple4 55 1a 8b
MediumPurple1 ab 82 ff
MediumPurple2 9f 79 ee
MediumPurple3 89 68 cd
MediumPurple4 5d 47 8b
thistle1 ff e1 ff
thistle2 ee d2 ee
thistle3 cd b5 cd
thistle4 8b 7b 8b
dark blue 00 00 8b
DarkBlue 00 00 8b
dark cyan 00 8b 8b
DarkCyan 00 8b 8b
dark magenta 8b 00 8b
DarkMagenta 8b 00 8b
dark red 8b 00 00
DarkRed 8b 00 00
light green 90 ee 90
LightGreen 90 ee 90