Faces can have various foreground and background colors. When you specify a color for a face—for instance, when customizing the face (see Face Customization)—you can use either a color name or an RGB triplet.
A color name is a pre-defined name, such as ‘dark orange’ or
‘medium sea green’. To view a list of color names, type M-x
list-colors-display. To control the order in which colors are shown,
list-colors-sort. If you run this command on a
graphical display, it shows the full range of color names known to
Emacs (these are the standard X11 color names, defined in X’s
rgb.txt file). If you run the command on a text terminal, it
shows only a small subset of colors that can be safely displayed on
such terminals. However, Emacs understands X11 color names even on
text terminals; if a face is given a color specified by an X11 color
name, it is displayed using the closest-matching terminal color.
An RGB triplet is a string of the form ‘#RRGGBB’. Each of the R, G, and B components is a hexadecimal number specifying the component’s relative intensity, one to four digits long (usually two digits are used). The components must have the same number of digits. For hexadecimal values A to F, either upper or lower case are acceptable.
The M-x list-colors-display command also shows the equivalent RGB triplet for each named color. For instance, ‘medium sea green’ is equivalent to ‘#3CB371’.
You can change the foreground and background colors of a face with M-x set-face-foreground and M-x set-face-background. These commands prompt in the minibuffer for a face name and a color, with completion, and then set that face to use the specified color. They affect the face colors on all frames, but their effects do not persist for future Emacs sessions, unlike using the customization buffer or X resources. You can also use frame parameters to set foreground and background colors for a specific frame; See Frame Parameters.