Appendix D. Color Names and Values

The first thing you need to learn about color is how to specify exactly the color you want; after all, there are a lot of different hues, tones, and shades and it's important you choose the right ones.

In XHTML there are two key ways of specifying a color:

  • Hex codes: These are six-digit codes representing the amount of red, green, and blue that make up the color, preceded by a pound or hash sign # (for example, #333333).

  • Color names: A set of names that represent over 200 colors, such as red, lightslategray, and fuchsia.

In addition, when writing CSS style sheets you can also specify colors using RGB color values. Here, numbers between 0 and 255 represent the amount of red, green, and blue that make up each color.

Using Hex Codes to Specify Colors

When you start using hexadecimal codes (or hex codes for short), they can be a little daunting because they use a mix of numbers and letters to represent colors. While we are used to numbers that are represented with 10 digits (0−9), hexadecimal codes are represented with 16 digits (0−9 and A-F). The table that follows provides some examples of colors and their hex values; we will come back to look at Understanding Hex Codes shortly, once you've seen what they're trying to represent.

Color

Hexadecimal Code

Black

#000000

White

#FFFFFF

Red

#FF0000

Green

#00FF00

Blue

#0000FF

Purple

#800080

The idea that colors are represented by a mix of numbers and letters might seem a little strange, but what follows the # sign is actually ...

Get Beginning HTML, XHTML, CSS, and JavaScript® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.