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:
- Personality. Three words for how the site should feel: calm, precise and trustworthy, or playful, warm and loud. Color carries mood quickly, and knowing the mood stops you from picking a color you merely like.
- Constraints. Does the site have a logo with colors already? Does the content include photos or charts that will compete with the palette? Will it have a dark mode? Is it text-heavy?
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:
- From the brand. If a logo exists, take its dominant color. The color picker from image can read it from a screenshot.
- From the subject. Finance and healthcare often lean toward blues and greens for calm and trust. Food and energy brands often use warm reds, oranges and yellows. These are tendencies, not rules, and standing out from competitors is sometimes the better choice.
- From a photo or mood board. Sample two or three colors from an image you like, and choose the most distinctive.
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.
Step 3: generate related colors
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):
- #C2E1FF
- #70B9FF
- #0A86FF
- #005DB8
- #003466
Complementary (the base and its opposite on the wheel, plus variations):
- #1E90FF
- #7ABDFF
- #F47800
- #FF8D1E
- #0058AD
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:
- 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. - 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.
| Role | Used for | Example (light) |
|---|---|---|
--paper | Page background | #EEF1F7 |
--surface | Cards and panels | #FFFFFF |
--ink | Main text | #141735 |
--muted | Secondary text | #4F5678 |
--line | Dividers and borders | #CBD2E3 |
--btn | Primary button fill | #1A1E4F |
--accent | Links, focus ring, highlights | #BF2163 |
--success, --warning, --error | Status 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:
| Pair | Ratio | Result |
|---|---|---|
--ink #141735 on --paper #EEF1F7 | 15.42:1 | Passes, and exceeds AAA |
--muted #4F5678 on --paper | 6.32:1 | Passes |
--accent #BF2163 on --paper (links) | 5.14:1 | Passes |
White text on --accent | 5.81:1 | Passes |
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:
- #66B3FFlighter
- #1F8FFFbase
- #007AF5hover
- #006BD6pressed
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:
- Use a very dark navy or grey for the page instead of pure black, and a slightly lighter shade for cards so layers are visible.
- Use an off-white for text instead of pure white.
- Lighten the accent. A color that works on a light page often looks too dark on a dark one. This site's rose accent is
#BF2163in light mode and#FF77A9in dark. - Retest every pair.
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:
- Every color in the stylesheet comes from a variable, with no stray hex codes in components.
- Every text pair has been measured, including secondary text, links and button labels.
- Form field borders, icons and focus rings reach 3:1 against what is around them.
- Hover, pressed, focus and disabled states exist for every interactive element, and they are distinguishable in greyscale.
- Status colors are paired with an icon or a word.
- The page works in dark mode, if you support it, and each pair is rechecked there.
- 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
- Too many colors. Each color you add needs states, contrast checks and a dark version. Fewer is easier to keep consistent.
- Accents everywhere. If everything is highlighted, nothing is.
- Choosing colors only on your own screen. Check on a phone and in a bright room.
- Using color as the only signal. Pair color with text or icons.
- Skipping the neutrals. They determine the whole feel more than the brand color does.
- 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.