What HTML color names are
A named color is a keyword you can write instead of a numeric code: color: tomato means exactly the same as color: #ff6347. People search for them as HTML color names because they started in HTML attributes such as bgcolor, but today they are defined by CSS and work anywhere a CSS color is accepted, including SVG, the canvas API and inline style attributes.
All named colors are sRGB colors and all are fully opaque. Each one is just a shortcut for a fixed HEX value, so the browser treats tomato and #ff6347 identically.
The CSS Color Level 4 list
The current definition is CSS Color Module Level 4, section 6.1. Its table lists 148 opaque named colors, which is the set on this page. A few details from the specification:
- Case does not matter. The names are ASCII case-insensitive, so
DodgerBlue,dodgerblueandDODGERBLUEare the same color. They are normally written in lowercase. - Some names are synonyms.
aquaandcyanare both#00ffff, andfuchsiaandmagentaare both#ff00ff. Every name containing gray also has a grey spelling (gray/grey,darkslategray/darkslategreyand five more pairs). That leaves 139 distinct colors. - Where the names come from. Sixteen came from the VGA palette and were adopted into HTML. Most of the rest come from a version of the X11 color list used on Unix systems, which was adopted into SVG and later CSS.
rebeccapurple(#663399) is the newest name, added in CSS Color Level 4. It honors Rebecca Meyer, the daughter of CSS author Eric Meyer, who died in 2014 on her sixth birthday; the CSS Working Group accepted the proposal that June.- Two special keywords are not in the 148.
transparentis transparent black. The spec counts it as a named color, but it has its own section rather than a row in the table of 148 opaque colors.currentcolor(often writtencurrentColor) means the element's owncolorvalue, soborder: 1px solid currentcolorfollows the text color.
The specification also says plainly that the names are kept for compatibility and that their use is not encouraged: they are spread unevenly across the color range and are not consistent with each other. For example, darkgray (#a9a9a9) is lighter than gray (#808080).
The 16 basic HTML 4 colors
HTML 4.01 defined only these sixteen. They are still valid in CSS with the same values.
| Name | HEX | Name | HEX |
|---|---|---|---|
aqua | #00FFFF | navy | #000080 |
black | #000000 | olive | #808000 |
blue | #0000FF | purple | #800080 |
fuchsia | #FF00FF | red | #FF0000 |
gray | #808080 | silver | #C0C0C0 |
green | #008000 | teal | #008080 |
lime | #00FF00 | white | #FFFFFF |
maroon | #800000 | yellow | #FFFF00 |
How the hue groups are worked out
Names don't always describe the color, so the groups are computed from each color's value. Pale colors with almost no tint (OKLCH lightness of at least 94% and chroma below 0.042) go to whites, and colors with almost no chroma go to grays. Browns are orange-to-gold hues that are darker or more muted than orange and gold, plus pale beiges such as wheat and bisque, and dark, moderately saturated reds such as brown itself. Everything else is grouped by its HSL hue angle. Names ending in white, gray or grey, or brown stay in that group, so navajowhite sits with the whites even though it is a fairly strong beige.
A few results may surprise you: olive is grouped with the greens, lavender (hue 240°) with the blues, tomato with the reds and lightseagreen with the cyans.
Worked example: the nearest name to #FF6600
The nearest-name finder converts your color and every named color to OKLab, a color space designed so that equal distances look about equally different, and measures the straight-line distance, called deltaE OK. For #FF6600 the closest three are:
| Name | HEX | deltaE OK |
|---|---|---|
tomato | #FF6347 | 0.0399 |
orangered | #FF4500 | 0.0532 |
coral | #FF7F50 | 0.0545 |
CSS Color 4 treats a deltaE OK of 0.02 as one just noticeable difference in its gamut-mapping rules, so tomato is about two noticeable steps from #FF6600: close, but visibly different side by side. A distance of 0 means an exact match, as with #808080 and gray.
Names or HEX codes?
- Names are easy to read in prototypes, demos, teaching material and debugging (
outline: 2px solid red), where the exact shade does not matter. - HEX, RGB, HSL or OKLCH suit design systems and brand colors, because a design almost never lands exactly on one of the 139 named values, and numbers can be adjusted step by step.
- Custom properties such as
--brand: #4f46e5give you a readable name for your own colors, which is what most people want from a color name in the first place.
System colors
CSS also has system color keywords such as Canvas, CanvasText, LinkText, ButtonFace, ButtonText, Field, Highlight and AccentColor. They are not fixed values: they reflect the colors chosen by the browser, the operating system or the user, follow the element's color scheme (light or dark), and expose the user's palette in forced colors mode, such as Windows high contrast. Older keywords such as ActiveBorder and InactiveBorder are deprecated. Use system colors in matching pairs, such as CanvasText on Canvas, because other combinations are not guaranteed to contrast.
Common mistakes
- Expecting dark to mean darker.
darkgrayis lighter thangray, andlightpinkis darker thanpink. Check the code, not the name. - Assuming a name exists. Common words such as
darkyellow,lightredandlightorangeare not CSS colors. An unknown name makes the whole declaration invalid, so the browser ignores it. - Skipping the contrast check. A name tells you nothing about readability:
yellowtext onwhitehas a contrast ratio of 1.07:1. - Quoting the name.
color: "red"is a string, not a color, so the declaration is invalid. Writecolor: red.