Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
HTML and CSS
Constants
 Color Table
Color Table
Note   Before printing this or any of the related pages on a color printer, select "Print background colors and images" from the Advanced tab of the Internet Options dialog box in Windows Internet Explorer.

Colors can be specified in HTML pages in two ways—by using numbers to denote an RGB color value, or by using a color name.

RGB Notation

An RGB color value normally consists of a '#' immediately followed by a triad of two-digit hexadecimal numbers specifying the intensity of the corresponding color: (R)ed, (G)reen, and (B)lue. For example, the color value #FF0000 is rendered red because the red number is set to its highest value, FF (or 255, in decimal).

Each of the following style rules refer to the same color: namely, red. The three digit short-hand form is converted into the six-digit form by replicating digits (#F00 becomes #FF0000). The "functional" RGB notation uses a comma-separated list of decimal or percentage values.

EM { color: #f00; }              /* #rgb */
EM { color: #ff0000; }           /* #rrggbb */
EM { color: rgb(255, 0, 0); }    /* integer range 0 - 255 */
EM { color: rgb(100%, 0%, 0%); } /* float range 0.0% - 100.0% */ 
EM { color: red; }               /* color keyword */ 

Standards-Compliant Mode

When you use the !DOCTYPE declaration to specify standards-compliant mode, Microsoft Internet Explorer 6 and later versions ignore style sheet declarations that do not comply with Cascading Style Sheets (CSS), Level 1 (CSS1). According to CSS 1, colors specified with hexadecimal RGB values must have a leading '#' character. Values like "FFFFFF" are ignored, not treated the same as "#FFFFFF" (also known as white) as in previous versions of Internet Explorer. This affects all CSS attributes and properties that accept an RGB color value.

Standard HTML Colors

Only 16 color "keywords" (names) are defined by the HTML 4.01 standard. These colors can always be rendered properly, regardless of the color resolution of the user's display card.

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

The CSS, Level 2 Revision 1 (CSS2.1) specification includes "orange" (#FFA500) for a total of 17 color keywords.

Additional Color Names

In addition to the colors listed above, Internet Explorer supports a wide variety of named colors. Click the Show Me button below to see a dynamic table of colors that can be sorted by column headers. Not all browsers support these additional named colors; therefore, when specifying color values for Web pages targeted to work across different browsers, use the RGB color values.

This feature requires Microsoft Internet Explorer 5 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

System Colors

You can also leverage the Microsoft Windows system colors that users have chosen to display various user interface (UI) components. Unlike the named colors however, user-defined system colors have no numeric RGB equivalent because the exact color is not known until the Web page is viewed on the user's system. Users can choose their own system color scheme from the Windows Control Panel.

Not all of the system colors are appropriate for a background or text color; however, some of them are intended to be used in combination. The following table demonstrates appropriate text and background colors, as they would appear on a Windows Vista system with default colors:

CaptionText on ActiveCaption, ButtonText on ButtonFace, WindowText on Window, etc.

Note   The system color names have been deprecated in the CSS, Level 3 (CSS3) recommendation.

Related Topics

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker