Stop 04 · CSS FundamentalsTopics · 7/9

Colors and Typography

Part of the Web Development Roadmap

In short

Most of a website is text and colour. Pick readable fonts, sensible sizes and colours with enough contrast, and even a plain page looks professional.

Colours can be written as names, hex, rgb or hsl, and typography covers font family, size, weight, line height and spacing. Good contrast and readable text matter more than fancy fonts.

The jaadu stands before a wardrobe holding up a deep purple kurta beside a single golden scarf, with a few grey outfits hanging neatly behind.

Think of it like this

Dressing for a wedding

Wear one main colour, one accent and neutral shoes, and you look sharp. Wear seven bright colours at once and people squint. A website is the same: one main colour, one accent, a few greys, and a font that's easy to read even from the back row.

Watch it happen

Ways to write the same colour

Hex

  • #6d28d9
  • Short and very common
  • Copied straight from design tools
  • #6d28d980 adds 50% transparency

HSL

  • hsl(263 70% 50%)
  • Hue, saturation, lightness
  • Easy to make lighter or darker shades
  • hsl(263 70% 50% / 0.5) for transparency

Both describe the same colour. Use hex when copying from a design, HSL when you want to tweak shades by hand. rgb() works too.

The big ideas

What you need to know

A small palette

One primary colour, one accent and a few greys. Store them in CSS variables so they're easy to change everywhere.

Contrast matters

Text needs strong contrast with its background. Light grey on white looks stylish but is hard to read, especially on a phone in sunlight.

Font stacks

font-family lists fallbacks, like "Inter", system-ui, sans-serif. If the first isn't available, the next one is used.

Size and spacing

Use rem for font sizes (1rem is usually 16px), a line-height around 1.5 for body text and a comfortable line length.

See it in code

Walk through the code

css
1@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap");2 3:root {4  --primary: #6d28d9;5  --accent: #f59e0b;6  --text: #1f2937;7  --bg: #ffffff;8}9 10body {11  font-family: "Inter", system-ui, sans-serif;12  font-size: 1rem;13  line-height: 1.6;14  color: var(--text);15  background: var(--bg);16}17 18h1 {19  font-size: 2.5rem;20  font-weight: 700;21  color: var(--primary);22}23 24.price {25  color: var(--accent);26  font-weight: 700;27}

1/4Load the Inter font in two weights from Google Fonts.

A small, consistent theme. You can also load Google Fonts with a <link> tag in the head, which is usually a little faster.

Save yourself the pain

Common mistakes

Oops

Using four or five different fonts on one page.

Do this instead

Stick to one or two families. Use weight and size for variety instead.

Oops

Setting font sizes in px everywhere.

Do this instead

Use rem so text scales when users increase their browser's font size.

Your mission

Theme a plain page

~20 min

Quick check

Why use font-family: "Inter", system-ui, sans-serif instead of just "Inter"?

Go deeper

  1. 1Pick a small palette of one main colour, one accent and a few greys, and stick to it.
  2. 2Load one Google Font and set a comfortable line-height of about 1.5 for body text.
  3. 3Check text contrast with the DevTools colour picker or an online contrast checker.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge