Frontend Master

JavaScript Curriculum

Typography
+55 XP

Typography

easy
~30 min·55 XP

The coffee shop page has good structure and spacing, but the text feels generic. The right typography choices will make it feel crafted and professional — without a single image.

Typography

Typography is the visual presentation of text. On the web, it is controlled almost entirely through CSS. Getting typography right transforms a plain HTML document into something that feels intentional and crafted.

Font Properties

Five properties control how individual characters look:

typography.css
The Grind Coffee
font-family

The typeface. Always provide fallbacks: font-family: "Brand Font", sans-serif. The browser uses the first available font.

Current CSS
h1 {
  font-family: sans-serif;
  font-weight: 400;
  font-style: normal;
  text-transform: none;
  letter-spacing: normal;
}
💡Use rem for font sizes, not px
rem (root em) is relative to the root font-size — usually 16px. Using rem means your type scales when the user increases their browser font size. Always use rem for font-size in production. The conversion is simple: 1rem = 16px, 1.5rem = 24px, 2rem = 32px.

Type Scale — Consistent Visual Hierarchy

A type scale is a set of font sizes related by a consistent ratio. Instead of picking random sizes, you multiply a base size by a ratio to get each step. This creates visual harmony:

type-scale.css
base16px
3xlCoffee50.52px
2xlCoffee37.9px
xlCoffee28.43px
lgCoffee21.33px
baseCoffee16px
smCoffee12px
xsCoffee9px
CSS Variables
:root {
  --text-xs: 9px;
  --text-sm: 12px;
  --text-base: 16px;
  --text-lg: 21.33px;
  --text-xl: 28.43px;
  --text-2xl: 37.9px;
  --text-3xl: 50.52px;
}
ℹ️CSS custom properties for type scale
Define your type scale as CSS variables in :root, then use them throughout. This makes changing the entire type scale a one-line edit — just change the base size or ratio and regenerate.

line-height — The Most Underrated Property

Line height controls the space between lines of text. It's the single biggest factor in body text readability:

line-height.css
font-size16px
line-height1.6

The best coffee starts before the sun rises. Our roasters arrive at 5am to sort, roast, and cup every single batch. No shortcuts. No compromises. Just coffee the way it should be.

16px
font-size
1.6
line-height
26px
computed leading
✓ Good readability range (1.6). Body text sweet spot: 1.4–1.7.
p {
  font-size: 16px;
  line-height: 1.6; /* unitless — scales with font-size */
  /* computed: 16px × 1.6 = 26px per line */
}
⚠️Always use unitless line-height
Write line-height: 1.6, not line-height: 1.6em or line-height: 25.6px. A unitless value multiplies the current font-size — so if a child element has a different font-size, line-height scales correctly. Using units creates inheritance bugs.

Your Challenge

Apply a full typography system to the coffee shop page — font stack, heading hierarchy, comfortable line-height, and styled navigation labels.

Challenge

Set a font stack on body, create a clear heading hierarchy using font-size and font-weight, set comfortable line-height on paragraphs, style the nav links with letter-spacing and text-transform, and use text-align to center the hero section.

font-familyfont-sizefont-weightfont-styleline-heighttext-alignletter-spacingtext-transformemremtype-scale
Typography | Nexus Learn