You've found a green that suits the book button. Then it turns out you also need a pale green for an info box background, a dark green for text, and a slightly darker green for hover. If you pick all four by feel, they look like four different brands of paint.
Picking colours for a UI isn't only taste. There's a method you can repeat and check. Picture a paint colour card at a hardware shop. One strip holds seven boxes, from the palest green to the darkest. All of them are the same green, only mixed with more white or more black. In UI, a strip like the one on the paint card is called a colour scale. Each box is one version of a brand colour (the colour a business is known by, here the green of Mist Homestay), from the lightest to the darkest. Each version has its own job.
HSL: three numbers you can set
In CSS, colours are often written as a hex code, like #15803d. It is a # sign, then six digits and letters that say how much red, green and blue the colour has. A hex code is hard to change in your head. HSL is another way to write a colour in CSS. It splits a colour into three numbers that are easier to understand:
- Hue (0 to 360): where the colour sits on the colour wheel. Red 0, green 120, blue 240.
- Saturation (0% to 100%): how colourful it is. 0% means grey.
- Lightness (0% to 100%): 0% black, 100% white, 50% the fullest colour.
Mrs. Sri's green #15803d in HSL is about hsl(142 72% 29%): hue 142, saturation 72%, lightness 29%. Modern CSS separates the three numbers with spaces. The old version with commas, hsl(142, 72%, 29%), still works too.
To make a shade (a darker version), lower the Lightness. To make a tint (a lighter version), raise the Lightness. Hue and saturation don't change, so the colour stays the same green.
One colour becomes one scale: 50 to 900
Each version in a scale is called a step. The steps are numbered from 50 (lightest) to 900 (darkest), as in Tailwind. Tailwind itself has added a step 950 since v3.3. Below is Mrs. Sri's green scale, stored as CSS variables in :root, like the font size scale and the spacing scale you have already seen. Each --green-... line holds one step. Hue and saturation stay fixed, and lightness steps down:
:root {
--green-50: hsl(142 72% 97%); /* a very soft background */
--green-100: hsl(142 72% 93%);
--green-200: hsl(142 72% 85%);
--green-300: hsl(142 72% 74%);
--green-400: hsl(142 72% 58%);
--green-500: hsl(142 72% 45%);
--green-600: hsl(142 72% 36%);
--green-700: #15803d; /* brand: hsl(142 72% 29%), button background */
--green-800: hsl(142 72% 24%);
--green-900: hsl(142 72% 20%); /* green text on a light background */
}
Then each step is checked with white text on it. The measure is the contrast ratio, with a minimum of 4.5:1 for normal text. You know both from the text hierarchy lesson:
| Step | Lightness | Hex | White text |
|---|---|---|---|
| 50 | 97% | #f2fdf6 |
1.04:1 |
| 300 | 74% | #8decb0 |
1.42:1 |
| 500 | 45% | #20c55d |
2.28:1 |
| 600 | 36% | #1a9e4a |
3.48:1 |
| 700 | 29% | #15803d |
5.02:1, passes |
| 800 | 24% | #116931 |
6.80:1 |
| 900 | 20% | #0e5829 |
8.58:1 |
- Step 700 is the first step that passes 4.5:1 with white text. That's why Mrs. Sri's button uses 700, not 500 in the middle of the scale.
- Steps 50 and 100 are for soft backgrounds, and 800 and 900 are for green text on a light background.
- A ready-made scale like Tailwind's isn't pure maths. Tailwind v3's
green-700is exactly#15803d. But itsgreen-800is#166534, which has been the hover colour of Mrs. Sri's page since the interactive text lesson. That colour is a little greyer than our computed#116931, because its saturation is lowered to 64%. Tailwind v4 writes its colours in OKLCH, another colour format named in the next section, and the values changed too:green-700isoklch(52.7% 0.154 150.069), about#008236. So a good scale is computed first, then tuned by eye.
Lightness isn't the brightness the eye sees
Guess first. hsl(142 72% 50%) (green) and hsl(221 83% 53%) (blue) both have a lightness of about 50%. Both are used as a button background with white text. Is the text on both buttons equally easy to read? Here is their contrast with white text:
| Colour | Hex | White text |
|---|---|---|
hsl(142 72% 50%) |
#24db67 |
1.84:1, fails |
hsl(221 83% 53%) |
#2563EB |
5.17:1, passes |
Not the same. White text on the blue button is easy to read; on the green button it almost disappears. Lightness in HSL is only a number from a formula, not the brightness the eye feels. Our eyes are far more sensitive to green than to blue. The WCAG luminance formula (the brightness formula behind the contrast ratio) records this with weights (the number each colour is multiplied by): green 0.7152, red 0.2126 and blue only 0.0722. That's why a green at 50% lightness looks much brighter than a blue at 50% lightness.
As a result, the first step that passes with white text moves with the hue. For example, use 72% saturation and the same lightness for each step as the green scale above. Blue (hue 240) already passes at step 400, green only at step 700, and yellow (hue 60) only at step 800. So pick colours with HSL, then always measure the contrast. CSS also has the oklch() format, whose lightness number is closer to the brightness the eye sees. But you still have to measure its contrast.
Picking colours from a photo
Another way to find colours: take them from a photo of the place itself. Figma has an eyedropper, a tool that reads the colour of one point in a picture. The colour picker in the browser's DevTools has an eyedropper too. This lesson's Lab uses a drawing of the morning view from the Mist Homestay terrace. These are two colours taken from that drawing:
| Taken from | HSL | Used for |
|---|---|---|
| The fog in the sky | hsl(210 25% 91%) |
the neutral hue: a bluish grey |
| The potato field | hsl(142 24% 48%) |
the brand hue: green 142 |
- The fog gives hue 210. All the greys on Mrs. Sri's page (
#f1f5f9,#e2e8f0,#475569,#1f2937) have a hue of 210 to 215 and carry very little colour. So the greys are the colour of fog, not a pure grey like#808080. Greys with a little hue feel like one family with the other colours on the page. - The potato field gives hue 142, but its saturation is only 24%, and white text on it is only 3.38:1. Photo colours are usually pale and greyish because of light and fog. So take only the hue, raise the saturation to 72%, then pick a lightness until white text passes. That gives
#15803d.
Careful, saturation changes contrast too. At 29% lightness, a green with 100% saturation (#009436) reaches only 3.97:1 with white text. Each time you change one of the numbers, measure again.
Four roles of colour in a palette
A UI palette (the set of colours one UI uses) usually has four roles:
- Primary: the brand colour with its scale. Here, green
#15803d. - Neutral: greys for text, borders and backgrounds. Here, bluish greys the colour of fog.
- Accent: a second bright colour besides the brand colour, used sparingly, and it is optional. Mist Homestay deliberately has no accent, so green stays the only colour that stands out.
- Semantic: colours for status. Red for errors (for example
#b91c1c, 6.47:1 on white), yellow or orange for warnings, green for success, blue for info.
How much of each colour to use on one screen is covered in the colour priority lesson, including the 60-30-10 rule.
⚠️ Colours that look right but fail the measurement
- Treating HSL lightness as brightness.
hsl(142 72% 50%)andhsl(221 83% 53%)have similar lightness. But with white text, the green is only 1.84:1 and the blue is 5.17:1. - Using a photo colour as it is for a button. The field green
hsl(142 24% 48%)with white text is only 3.38:1. Take its hue, then set its saturation and lightness. - Pure grey next to a brand colour. Give the greys a little hue from the photo or from the brand colour.
- A random palette generator without checking. A palette from a generator still has to have its contrast measured, one pair of colours at a time.
TL;DR: HSL (Hue, Saturation, Lightness) writes a colour as three numbers: its place on the colour wheel, how colourful it is, and how light it is. A shade (a darker version) is made by lowering Lightness, a tint (a lighter version) by raising it. Hue and Saturation stay. From one brand colour (the colour a business is known by), build a colour scale: several versions of that colour, called steps, from 50 (lightest) to 900 (darkest). Then check each step with white text. For Mrs. Sri's green, the first step that passes the 4.5:1 contrast ratio is 700 (#15803d, 5.02:1). HSL lightness isn't the brightness the eye sees: with white text, a green at 50% lightness is only 1.84:1, a blue at 53% reaches 5.17:1. So always measure the contrast. From a photo of the view at Mist Homestay, take only the hue: the fog gives hue 210 for the greys, the potato field gives hue 142 for the green. A palette has four roles: primary (the brand colour), neutral (greys), accent (a second bright colour, optional) and semantic (status colours).
⚡ Shades and tints through Lightness
Meaning: HSL writes a colour as three numbers: Hue (its place on the colour wheel), Saturation (how colourful it is) and Lightness (how light it is). The green of Mrs. Sri's button, hex code #15803d, is about hsl(142 72% 29%). A shade (a darker version): lower the Lightness. A tint (a lighter version): raise the Lightness. Hue and Saturation stay, so the result is still the same green.
⚡ One colour becomes a 50 to 900 scale
Write:
:root {
--green-50: hsl(142 72% 97%); /* a very soft background */
--green-500: hsl(142 72% 45%);
--green-700: #15803d; /* brand: hsl(142 72% 29%), button background */
--green-900: hsl(142 72% 20%); /* green text on a light background */
}
Guess first: each line of this code is one step of a green scale. A green button with white text has to pass a contrast ratio of 4.5:1. Which step does it use?
700, the first step that passes (5.02:1). Step 500 in the middle is only 2.28:1.
Meaning: A colour scale is one colour in several steps, from 50 (lightest) to 900 (darkest). In this code each step is stored as a CSS variable (a name like --green-... that holds one colour), with hue and saturation fixed and lightness going down. Steps 50 and 100 are for soft backgrounds, 800 and 900 for green text on a light background.
⚡ Lightness isn't what the eye sees
Meaning: A green and a blue at about 50% lightness don't look equally bright. The contrast ratio of white text on the green button is only 1.84:1, on the blue button 5.17:1. Our eyes are far more sensitive to green, so the green looks much brighter. Pick colours with HSL, then always measure the contrast.
⚡ Four roles of colour
Meaning: A UI palette (the set of colours a UI uses) has four roles. Primary: the colour of the brand, with its scale. Neutral: greys for text, borders and backgrounds. Accent: a second bright colour besides the brand colour, optional. Semantic: status colours, such as red for errors, yellow for warnings, green for success and blue for info.