CSS Named Colors and How to Choose Web Colors That Work

How CSS color names like tomato and slategray work, when to use names versus HEX codes, and how to build tints, shades and readable text colours.

Updated September 29, 2026 6 min read

Use the free HTML Color CodesPick colours and browse all 140+ CSS color names with HEX and RGB

Sooner or later every web project needs colours written down as code: a brand blue for buttons, a soft background for alerts, a darker shade for hover states, and a text colour that stays readable on all of them. You can type #4f46e5 or rgb(79, 70, 229), or you can type tomato and let the browser work it out. Knowing which to use, and how to derive a whole set of related colours from one starting point, saves a lot of guessing.

This guide explains CSS named colours and where they come from, when names are fine and when codes are better, how tints and shades are created, and how to check that text on your colours is readable.

What CSS named colours are

CSS lets you write a colour as a keyword instead of a number. Browsers recognise more than 140 of these names, from aliceblue to yellowgreen. Each name maps to one exact colour:

.alert {
  background: lavenderblush;
  border-left: 4px solid crimson;
  color: darkslategray;
}

is exactly the same as:

.alert {
  background: #fff0f5;
  border-left: 4px solid #dc143c;
  color: #2f4f4f;
}

The list has an odd history. Most names came from the X11 window system's colour list and were adopted by early browsers before being standardised in CSS. That explains some surprises:

  • gray and grey are both valid, as are darkgray and darkgrey, and so on for every gray name.
  • darkgray is lighter than gray. gray is #808080 while darkgray is #a9a9a9, a quirk inherited from the old list.
  • rebeccapurple (#663399) was added later in memory of Rebecca Meyer, daughter of CSS expert Eric Meyer.

Names are case-insensitive, so Tomato and TOMATO also work, though lowercase is the convention.

Names versus codes

Use named colours when Use HEX, RGB or HSL when
Prototyping and quick demos Matching an exact brand colour
Writing examples and teaching Building a consistent design system
Debugging (outline: 2px solid red) You need transparency (rgb(0 0 0 / 50%))
The name happens to be exactly the colour you want You need to adjust lightness or saturation systematically

Named colours are fully supported in every browser and perfectly safe to ship. Their limitation is choice: 140 names cannot cover the millions of colours a design needs. Most production code uses HEX or HSL values, often stored in CSS custom properties:

:root {
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --surface: #f8fafc;
}

For a detailed explanation of the numeric formats and how to convert between them, see our guide to HEX, RGB, HSL and CMYK colour codes.

Tints, shades and building a palette

One brand colour is never enough. You need lighter versions for backgrounds and darker ones for hover states and borders.

  • A tint mixes the colour with white. A 20% tint is 80% colour, 20% white; an 80% tint is a pale wash suitable for backgrounds.
  • A shade mixes the colour with black, for pressed states, borders and text on light backgrounds.

Mixing in RGB is simple: for each channel, move the value towards 255 for a tint or 0 for a shade. For a colour with red 79 and a 50% tint, the new red value is 79 + (255 − 79) × 0.5 = 167. Modern CSS can also do this in the browser with color-mix(in srgb, #4f46e5 50%, white), supported in current versions of major browsers.

Explore colours with the HTML Color Codes tool

Our HTML Color Codes tool combines a picker, a converter and a searchable list of every named colour.

  1. Open HTML Color Codes.
  2. Use Pick a colour or type a HEX code, or paste any CSS colour into the field below it, such as tomato, rgb(34 197 94) or hsl(200 80% 50%).
  3. Read the Colour codes panel: HEX, RGB, HSL and the Nearest name. Click the copy button next to any of them.
  4. Look at Tints and shades (click to use): eight steps from light to dark. Click one to load it into the picker and see its codes.
  5. Check the contrast line, which gives the contrast ratio with white text and with black text, next to the reminder that WCAG AA needs 4.5:1 for body text.
  6. Browse the named colour table below. Use Search by name or hex…, filter by Colour family (red, orange, yellow, green, cyan, blue, purple, pink, brown, gray, white) and choose Sort: A–Z, Sort: hue or Sort: lightness.
  7. Click a name, HEX or RGB value in the table to copy it, or click the swatch to load that colour into the picker.

Readable text on coloured backgrounds

Contrast ratio compares the relative luminance of two colours on a scale from 1:1 (identical) to 21:1 (black on white). The WCAG accessibility guidelines ask for at least 4.5:1 for normal body text and 3:1 for large text (roughly 24 px regular or 19 px bold) at level AA.

Practical rules:

  • Light backgrounds need dark text, and mid-tone brand colours often fail with both white and black. The tool's contrast line shows which works better.
  • Do not rely on a colour's name. orange with white text has a low ratio even though it looks bold.
  • Test hover and disabled states too, not just the default button.

For checking any two specific colours against both AA and AAA levels, use the Color Contrast Checker.

Other ways to find colour codes

Browser developer tools

Click any colour swatch in the Styles panel of your browser's developer tools to open a picker with an eyedropper and format switching. Many also show the contrast ratio for text. This is the fastest way to adjust colours on a live page.

Design tools

Figma, Sketch and similar tools show HEX and RGB for every fill and can export styles. They are where brand palettes usually live.

From an image or screen

To take a colour from a photo or logo file, use the Image Color Picker. For a quick picker with more formats, try the Color Picker, and for converting between formats in bulk, the Color Converter.

Frequently asked questions

How many colour names does CSS support?

More than 140. The exact count depends on whether you count both spellings of the gray names, such as darkgray and darkgrey, which produce identical colours.

Are CSS colour names supported in all browsers?

Yes. The named colours are part of the CSS standard and work in every modern browser and in HTML email.

Why is darkgray lighter than gray?

It is a historical accident. The names came from an older colour list where darkgray was defined as #a9a9a9, while CSS defined gray as #808080.

What is the difference between a tint and a shade?

A tint is a colour mixed with white, making it lighter. A shade is mixed with black, making it darker.

Should I use white or black text on my brand colour?

Use whichever gives the higher contrast ratio, and make sure it reaches at least 4.5:1 for body text. The tool shows both ratios for the selected colour.

Try it now: HTML Color Codes

Loading tool…