Skip to content

Type and Color

You'll choose two fonts and four colors, set them once as CSS variables, and use them everywhere so the whole site looks like one thing.

About

A site looks designed when it uses a small number of choices consistently. Pick one font for headings and one for body text, or just one for both. Pick a text color, a background, an accent and a muted gray. Put them all in CSS custom properties at the top of your stylesheet, and from then on never type a hex code anywhere else. The payoff comes in the last requirement, when you change one value and the whole site follows.

At a glance

Per requirement
15 XP
Completion bonus
75 XP
Requirements
5
Takes
One evening
Skill level
Beginner (done it a few times)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own

Requirements

  1. 1
    Choose a type pairing and write down why. Try one serif and one sans, or one of each role from the system font stack. The free options are the fonts already on the device, or one file from a free foundry, and either is fine. Avoid loading more than two font files, because each one slows the page. Take a photo of a notebook page with the pairing and one sentence on why you picked it. Photo
  2. 2
    Define your palette as custom properties in :root. Start with --text, --bg, --accent and --muted at minimum. Check the contrast of your text on your background with a contrast checker, aiming for 7:1 and accepting 4.5:1. Take a screenshot of the :root block and the contrast result. Photo
  3. 3
    Use the variables everywhere and delete every loose value. Search your CSS for # and rgb(. Every hit outside :root gets replaced with var(), so that every color on the site comes from one place. Take a screenshot of the search showing zero results outside :root. Photo
  4. 4
    Set a type scale with no more than five sizes. Body, small, h3, h2 and h1 is plenty. Use rem units, and a ratio of 1.25 between steps is a safe place to start. Take a screenshot of a page with all five sizes visible. Photo
  5. 5
    Change the accent color in one place and watch the site follow. If the variables are wired right, one edit changes the links, the buttons and the borders all at once. Film yourself changing the value and reloading the page. Video