Skip to content

How to Build a Website Color Palette That Stays Readable

By Durim Hoti · Last updated

A palette that looks good in a row of swatches can still fail on a real page: white text on a light blue button, or a yellow link nobody can read. Building a palette therefore has two parts: choosing colors that fit together, and deciding which text color goes on each.

Build a palette step by step

  1. Open the color palette generator.
  2. Enter your brand color as Starting color, or click Random palette for ideas.
  3. Choose a Scheme: analogous, complementary, triadic, split-complementary, tetradic or monochromatic.
  4. Click Copy all HEX or Copy CSS. Under the palette, the shades and tints of the starting color give you more steps.
  5. Check the text color for each color you will put text on.

Example: a complementary palette from #1D4ED8

The color palette generator with the starting color #1D4ED8 and the scheme Complementary. Five swatches: Base shade #102B77, Base #1D4ED8, Base tint #A5B8EF, Complement tint #E8CA77 and Complement #D8A71D. Below are the HEX list and the CSS variables --color-1 to --color-5.
Five colors from one: the blue, its shade and tint, and the yellow complement.
  • #102B77 – Base shade
  • #1D4ED8 – Base
  • #A5B8EF – Base tint
  • #E8CA77 – Complement tint
  • #D8A71D – Complement
Copy CSS
:root {
  --color-1: #102B77;
  --color-2: #1D4ED8;
  --color-3: #A5B8EF;
  --color-4: #E8CA77;
  --color-5: #D8A71D;
}

Which text color works on each swatch

We calculated the contrast of white text and of dark gray text (#111827) on each color, the same way the contrast checker does:

BackgroundWhite text#111827 text
#102B7712.87:1 (passes AA)1.37:1 (fails)
#1D4ED86.70:1 (passes AA)2.64:1 (fails)
#A5B8EF1.95:1 (fails)9.05:1 (passes AA)
#E8CA771.59:1 (fails)11.11:1 (passes AA)
#D8A71D2.21:1 (fails)7.99:1 (passes AA)

The result splits the palette in two: the shade and the base blue carry white text, the tints and the yellow complement need dark text. A yellow button with white text, a common mistake, reaches only 2.21:1. Named by their job, the variables look like this:

CSS
:root {
  --brand-dark: #102B77;   /* headings, footer background (white text) */
  --brand: #1D4ED8;        /* buttons, links (white text on buttons) */
  --brand-soft: #A5B8EF;   /* highlights, badges (dark text) */
  --accent-soft: #E8CA77;  /* notices (dark text) */
  --accent: #D8A71D;       /* small accents (dark text) */
  --text: #111827;
}

Other schemes from the same color

  • Analogous: #1DCBD8#1D8CD8#1D4ED8#2A1DD8#691DD8
  • Triadic: #1D4ED8#D81D4E#4ED81D#BBCAF3#0F276C
  • Monochromatic: #0C1F56#143797#1D4ED8#6C8CE6#BBCAF3

Analogous and triadic schemes give several strong, saturated colors, and one text color rarely works on all of them; check each one, or use them for accents and charts. Monochromatic stays in one hue and makes the text decision easy.

Common problems

White text is unreadable on some colors

Light and yellow colors need dark text, as the table shows. Decide the text color per color, not once for the whole palette.

The palette looks different on my site

Colors change with their neighbors and the amount of each. Use the brand color for small areas such as buttons, and the tints for larger surfaces.

Variables called --color-1 to --color-5 are hard to maintain

Rename them by their job, such as --brand or --accent, so a later color change doesn't require searching through the CSS.

My brand color comes from an image

Read it exactly first; see how to pick a color from an image.

What to do next

For the color formats behind the HEX codes, read HEX vs RGB vs HSL. The contrast rules are in the WCAG 2.2 specification.

FAQ

How many colors does a website palette need?
Usually one brand color with a lighter and a darker version, one accent color, and neutrals for text and backgrounds. The generator's five colors plus a dark text color and white cover most sites.
Which contrast ratio does text need?
WCAG 2 level AA asks for at least 4.5:1 for normal text and 3:1 for large text (about 24 px, or 19 px bold). Level AAA asks for 7:1 and 4.5:1.
Which scheme should I choose?
Complementary gives one clear accent; analogous looks calm because the hues are close; monochromatic stays within one hue. Try them with your brand color and keep the one whose colors you can assign a job to.
Can I start from a color in my logo?
Yes. Read the exact value with the image color picker, then paste it as the starting color in the palette generator.
Is the palette generated on a server?
No. The colors are calculated in your browser.

Try it and keep reading