NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.

HTML XHTML The Complete Reference
home » reference » appendix b » color values

Color Values

Style sheets support a variety of color measurement values, as shown in Table B-3. Appendix E provides a greater discussion of possible color values and names.

Color Format
Specification - defined named colors CSS color values can be defined using 16 color names: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow. body {font-family: Arial; font-size: 12pt; color: red;}
Browser - defined named colors Browsers define a variety of their own colors like mintcream. Appendix E provides a complete list of these extended colors, which should be avoided because of potential browser compatibility problems. #gap {color: khaki;}
Three-digit hexadecimal The three-digit hexadecimal format is unique to CSS and specifies color in the format of #RGB where R,G, and B are hexadecimal ranging from 0 to F. Given the lesser number of digits, it is obviously less expressive than the six-digit format. span {font-family: Helvetica; font-size: 14pt; color: #0CF;}
RGB CSS colors can also be defined using the keyword rgb , followed by three numbers between 0 and 255, contained in parentheses and separated by commas, with no spaces between them. RGB color values can also be defined using percentages. The format is the same, except that the numbers are replaced by percentage values between 0% and 100%. #p1 {color: rgb(204,0,51);}
p {color: rgb(0%,10%,50%);}
table b-3

TIP For maximum compatibility with older CSS implementations, developers are encouraged to use known name values or the six-digit hexadecimal format when specifying color.

(X)HTML Elements
CSS Properties
Back: CSS Measurements Next: CSS Selectors
< Home | About | Chapters | Examples | Errata | Reference | Site Map >