HTML and CSS understand 148 color names, from aliceblue to yellowgreen, and any other color as a hex, RGB or HSL code. Below is every named color with its codes, grouped by color and ordered light to dark, and a short guide to writing color codes.
How HTML color codes work
A color code tells the browser how much red, green and blue light to mix. The same color can be written in several ways, and every modern browser accepts all of them in HTML style attributes and in CSS.
One color, tomato, written five ways.
Format
Example
How it works
Hex
#FF6347
Two hex digits (00 to FF) each for red, green and blue.
Short hex
#F00
One digit per channel, doubled: #F00 is #FF0000. Only works for colors like that.
RGB
rgb(255, 99, 71)
Red, green and blue from 0 to 255, the same numbers as hex in decimal.
HSL
hsl(9, 100%, 64%)
Hue as an angle on the color wheel, then saturation and lightness.
Name
tomato
One of the 148 keywords below. Not case-sensitive.
Add transparency with an eight-digit hex (#FF634780 is tomato at about 50% opacity) or with a slash in the function, rgb(255 99 71 / 50%). To convert between formats, use the hex to RGB converter or the color picker, which also shows HSL, OKLCH and CMYK.
Using color codes in HTML and CSS
In CSS: color: #FF6347; sets text color, and background-color: tomato; sets the background.
In an HTML attribute: <p style="color: #FF6347"> colors one element. A stylesheet is easier to maintain for anything larger.
As a variable: define --brand: #FF6347; once on :root and use color: var(--brand); everywhere, so the color changes in one place.
Check readability: text needs enough contrast with its background. Test pairs in the contrast checker before you ship them.
The named colors are handy for quick tests, but most brands use exact hex codes. To find the name of any hex code, use the color name finder, which searches 923 named colors, or browse the color chart.
There are 148 named colors in CSS Color Level 4, counting spelling pairs such as gray and grey separately. Some share a color: aqua and cyan are both #00FFFF, and fuchsia and magenta are both #FF00FF.
What is the hex code for white and black?
White is #FFFFFF, or rgb(255, 255, 255). Black is #000000, or rgb(0, 0, 0). In short hex they are #FFF and #000.
Are HTML color names case-sensitive?
No. Tomato, tomato and TOMATO all give the same color. Hex codes are not case-sensitive either, so #ff6347 and #FF6347 are the same.
Should I use color names or hex codes?
Use hex, RGB or HSL codes for real designs, because the 148 names cover only a small set of colors. Names are fine for prototypes and examples.
What is rebeccapurple?
Rebeccapurple, #663399, was added to CSS in 2014 in memory of Rebecca Meyer, the daughter of CSS expert Eric Meyer. It is the newest named color.