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.
14.9.1 Color Names
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, customize
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.
14.9.2 RGB Triplets
An RGB triplet is a string of the form ‘
#RRGGBB’. Each of the primary color components is represented by a hexadecimal number between ‘
00’ (intensity 0) and ‘
FF’ (the maximum intensity). It is also possible to use one, three, or four hex digits for each component, so ‘
red’ can be represented as ‘
#fff000000’, or ‘
#ffff00000000’. The components must have the same number of digits. For hexadecimal values A to F, either upper or lower case are acceptable.
M-x list-colors-display command also shows the equivalent RGB triplet for each named color. For instance, ‘
medium sea green’ is equivalent to ‘
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.