Sub topic 3
Using Value Contrast to Build Hierarchy and Focus
Assume you know basic RGB color and can read simple CSS or Python. This chapter uses value contrast to organize attention, improve legibility, and build a small palette.
Value contrast creates hierarchy
Value describes how light or dark a color appears. Value contrast is the difference between nearby light and dark areas. Strong contrast attracts attention. Weak contrast makes elements recede.
Use the largest contrast for the main action or most important information. Use smaller differences for supporting content. For example, dark text on a light background can make a heading prominent, while a medium-gray label remains secondary.
Perceived lightness is not purely numeric
Equal numeric values do not look equally light. Human vision generally perceives yellow and green as brighter than blue or purple at similar channel values. Therefore, a blue and a yellow with the same HSV value can have different visual weight.
Check a palette in grayscale. If the intended hierarchy disappears, adjust value or lightness rather than relying on hue alone.
Contrast ratios and readable pairs
Accessibility tools calculate a contrast ratio from relative luminance, which estimates perceived brightness from the RGB channels. The ratio is:
(lighter luminance + 0.05) / (darker luminance + 0.05)
| Content | Common WCAG AA target |
|---|---|
| Normal text | 4.5:1 |
| Large text | 3:1 |
Use a contrast checker for final decisions. A visually attractive pair can still fail when used for small text.
Build a cohesive palette
- Choose one base hue for the brand or subject.
- Create a dark value for backgrounds or strong text.
- Create a light value for surfaces and spacious areas.
- Add one higher-saturation accent for actions.
- Reduce saturation for secondary elements.
- Test the palette in grayscale and with contrast tools.
Use HSL and HSV in code
HSL separates hue, saturation, and lightness. HSV uses value, defined by the brightest RGB channel. They organize similar ideas but produce different results.
:root {
--brand-hue: 210;
--brand: hsl(var(--brand-hue) 80% 45%);
--brand-light: hsl(var(--brand-hue) 80% 85%);
--brand-dark: hsl(var(--brand-hue) 80% 20%);
--brand-muted: hsl(var(--brand-hue) 25% 45%);
}import colorsys
r, g, b = 0.2, 0.4, 0.8
h, s, v = colorsys.rgb_to_hsv(r, g, b)
muted = colorsys.hsv_to_rgb(h, s * 0.5, v)
print(round(h * 360), muted)Exercise
A yellow button and a blue button have the same HSV value. Why might the yellow appear more prominent?
Show answer
Perceived lightness depends on the hue and human vision, not only the numeric HSV value. Compare them in grayscale and adjust their values or lightness.