Skip to content
Hex Color Picker

Blog

How to Build a Color Palette for a Website, Step by Step

By the Hex Color Picker Team. Published . 8 minute read.

To build a website color palette, start from one base color that fits the brand, add a few tinted neutrals for backgrounds and text, pick one accent for actions, assign each color a role, test every text pair for contrast, and store the result as CSS variables. Most sites need fewer colors than people expect: about three to five chosen colors plus a neutral scale and status colors.

This guide walks through a method you can follow in an afternoon, using real values from this site's own palette as the worked example. Each step has a clear output, so you finish with a set of tokens you can paste into a stylesheet.

Step 1: decide what the palette must do

A palette is a tool, so start with its job. Write two short lists:

For this site, the words were "clear, technical, a little playful", and the main constraint was that the colors the visitor picks are the stars of the page, so the interface itself should stay quiet.

Step 2: choose one base color

The base color is the one that appears in your most important elements: the logo, the main buttons, key links. Pick it by one of these routes:

Use the hex color picker to settle on an exact hex code, and write it down. We'll use dodgerblue, #1E90FF, as a generic example in the steps below.

Now explore colors that work with the base. The color palette generator builds five-color sets from any base using color-wheel relationships. For #1E90FF, it produces:

Monochromatic (the same hue at different lightness levels):

Complementary (the base and its opposite on the wheel, plus variations):

Each scheme has a different use. Monochromatic palettes are the safest and look cohesive. Complementary palettes give you a ready-made accent, here an orange against the blue. Complementary vs analogous color schemes compares all of them.

You don't need to use every color the tool returns. Treat the output as a menu, and pick two or three that you can imagine in the interface.

Step 4: add neutrals

Every site needs neutrals for backgrounds, borders and text, and they will cover most of the screen. Two decisions matter:

  1. Pure greys or tinted greys? A tinted grey carries a trace of your base hue and often feels more natural next to a brand color. This site's page background is #EEF1F7, a very pale grey with a hint of blue, and its text is #141735, a very dark navy instead of pure black.
  2. How many steps? Five or six is plenty: a page background, a surface (cards), a soft fill, a divider, a muted text color and a main text color.

Avoid pure black text on pure white for long reading. It has the maximum contrast, but a very dark color on a slightly off-white background is easier on the eyes for many people, while still passing every contrast test.

Step 5: choose an accent and status colors

The accent is the color that says "this is clickable" or "look here". It should be rare enough to stand out, which is a good reason not to use your base color for everything. For a blue base, a warm accent such as orange or coral stands out well. For this site, the base is a quiet navy and the accent is a rose, #BF2163.

Status colors communicate success, warning and error. Choose a green, an amber and a red, and don't rely on color alone: pair them with an icon or label. Use a darker amber than you think you need. Light yellows fail on white backgrounds.

Step 6: assign roles

This is the step most people skip, and it is the one that makes a palette usable. Give every color a job, and name it for the job, not for its color.

RoleUsed forExample (light)
--paperPage background#EEF1F7
--surfaceCards and panels#FFFFFF
--inkMain text#141735
--mutedSecondary text#4F5678
--lineDividers and borders#CBD2E3
--btnPrimary button fill#1A1E4F
--accentLinks, focus ring, highlights#BF2163
--success, --warning, --errorStatus messages#0E7048, #8A5300, #B3261E

Role-based names mean you can change a value without touching any component, and a dark mode is simply a second set of values for the same names.

Step 7: test the pairs

Before you commit, check each text-on-background pair against the WCAG contrast thresholds: 4.5:1 for normal text, 3:1 for large text and interface components. The color contrast guide explains how the ratio works.

For the example palette, the checks look like this:

PairRatioResult
--ink #141735 on --paper #EEF1F715.42:1Passes, and exceeds AAA
--muted #4F5678 on --paper6.32:1Passes
--accent #BF2163 on --paper (links)5.14:1Passes
White text on --accent5.81:1Passes

If something fails, adjust it, then test it again. A very common correction is to darken a bright brand color for text use, while keeping the bright version for large fills and decoration.

Test the status colors and the borders of form fields too, since interface components need 3:1.

Step 8: define states

Buttons and links need hover, pressed, focus and disabled states. HSL makes these easy to derive, because you change only the lightness. Starting from hsl(210, 100%, 56%), which rounds to #1F8FFF:

Hover is eight points darker, and pressed is fourteen. Check the contrast of each state, since the text on a button must stay readable when its color shifts. HSL for designers covers building states and scales this way.

Step 9: plan dark mode

If your site will have a dark theme, define it at the same time. Dark mode is not just inverted colors. These adjustments usually help:

In this site's dark theme the main text is #ECEEFB on #0D0F21 at 16.43:1, and the accent is #FF77A9 on the same page color at 7.64:1.

Step 10: write it down as CSS variables

Put the whole palette in one place:

:root {
  color-scheme: light dark;
  --paper: #EEF1F7;
  --surface: #FFFFFF;
  --ink: #141735;
  --muted: #4F5678;
  --line: #CBD2E3;
  --btn: #1A1E4F;
  --accent: #BF2163;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0D0F21;
    --surface: #161933;
    --ink: #ECEEFB;
    --muted: #A4ABD0;
    --line: #2A2F5C;
    --btn: #ECEEFB;
    --accent: #FF77A9;
  }
}

Then use only the variables in components. If you find yourself writing a raw hex code inside a component, add a role for it instead. The guide to colors in CSS shows the syntax details.

The 60-30-10 guideline

A common rule of thumb for how much of each color to use is 60-30-10: about 60% of the surface in a dominant neutral or base color, 30% in a supporting color, and 10% in the accent. It is only a heuristic, but it explains why a page with an accent on everything feels noisy, and one with a single accent feels organized. On this site, the dominant color is the pale page background, the supporting color is the white of the cards plus the navy of the text, and the accent appears only in links and focus rings.

A quick launch checklist

Before you ship, run through this list. It takes five minutes and catches most palette problems:

  1. Every color in the stylesheet comes from a variable, with no stray hex codes in components.
  2. Every text pair has been measured, including secondary text, links and button labels.
  3. Form field borders, icons and focus rings reach 3:1 against what is around them.
  4. Hover, pressed, focus and disabled states exist for every interactive element, and they are distinguishable in greyscale.
  5. Status colors are paired with an icon or a word.
  6. The page works in dark mode, if you support it, and each pair is rechecked there.
  7. The palette is documented in one place, with each role and its hex value, so the next person can extend it without guessing.

If you work with a designer, share the role table and the CSS variable block, not just a screenshot of swatches. Roles are what turn a set of pretty colors into a system.

Mistakes to avoid

  1. Too many colors. Each color you add needs states, contrast checks and a dark version. Fewer is easier to keep consistent.
  2. Accents everywhere. If everything is highlighted, nothing is.
  3. Choosing colors only on your own screen. Check on a phone and in a bright room.
  4. Using color as the only signal. Pair color with text or icons.
  5. Skipping the neutrals. They determine the whole feel more than the brand color does.
  6. Not storing the palette. A palette that lives only in a design file will drift from the code.

Frequently asked questions

How many colors should a website palette have?

Usually a base color, an accent, a neutral scale of about five steps, and three status colors. That is more entries than "five colors", but the neutrals and statuses play supporting roles.

What color should I choose for buttons?

Choose the color that stands out most against both your background and your text, and that passes 3:1 contrast against the page. Many sites use the accent for the main action and a neutral fill for secondary buttons.

Should I use the same palette in light and dark mode?

Use the same roles and similar hues, but adjust the values. Dark mode usually needs a lighter accent and softer text.

How do I pick colors from a photo?

Use the color picker from image to sample a few points, then run your favorite through the palette generator. The guide to picking colors from an image has tips.

Can I generate a palette automatically?

You can generate a starting point with the palette generator, but you still need to assign roles and check contrast yourself. That part decides whether the palette works.

Try it yourself

More guides