In the previous lesson the hierarchy came from size: the homestay name at 36px, the room name at 24px. But a room card on a phone screen is narrow. There is no space to make anything bigger, and the room name still has to be read first.
The answer is in the thickness of the letters. Font weight (often just called weight) is written as a number from 100 (thinnest) to 900 (heaviest). With weight alone you can show people what to read first, without making anything bigger. Imagine the notice board at a small shop: the heading is written with a thick marker, the details with a pen. The letters are about the same size, but the eye goes straight to the marker. On a web page, the marker writing is text with a heavier weight. Font pairing (choosing two fonts to use together) is like choosing clothes: a batik shirt with plain trousers looks good because they contrast, which means they are clearly different. Two different batik patterns clash (look bad together). Fonts are the same: a good pair is two fonts that are clearly different.
The font-weight numbers
In CSS, the weight of the letters is set with font-weight. These are the values used most:
| Value | Name | Used for |
|---|---|---|
| 300 | Light | Calm large text, 24px and up |
| 400 | Regular | Body text, paragraphs. Same as normal |
| 500 | Medium | Subheadings, labels, menus |
| 600 | Semibold | Small headings, emphasis |
| 700 | Bold | Headings, buttons, strong emphasis. Same as bold |
There are also 100 (Thin), 200 (Extra Light), 800 (Extra Bold) and 900 (Black), but an ordinary page rarely needs them. Each font has its own set of available weights: some fonts only have 400 and 700.
Hierarchy with weight: 2 to 3 weights
Here is Mrs. Sri's room card. Each paragraph (<p>) has a class (a name that CSS uses to pick it): .title for the room name, .subtitle for short details, and .body for the description. The hierarchy is made from font-weight:
<p class="title">Terrace Room</p>
<p class="subtitle">2 guests · queen bed · breakfast</p>
<p class="body">A first-floor room with a wooden terrace facing the potato garden.</p>
<style>
.title { font-weight: 700; } /* Bold: read first */
.subtitle { font-weight: 500; } /* Medium: supporting info */
.body { font-weight: 400; } /* Regular: the content */
</style>
.titleis heaviest (700), so the room name is what the eye catches first..subtitlesits in the middle (500): firmer than the body, but not competing with the title..bodyis 400, the same as the default weight of<p>. Writing it is still useful: people who read your code know that 400 is your choice.
Three weights like this are enough for a whole website. The practical rule is 2 to 3 weights, for example 400, 500 and 700. If you use 300, 400, 500, 600, 700 and 800 all together, nothing feels most important any more.
Weight contrast has to be visible
Guess first: a subheading at weight 500 and body text at weight 400, at exactly the same size and colour. Can you see the difference?
Barely. A step of 100 (400 to 500) is hard to see when weight is the only difference. When only the weight differs, jump at least 200: 400 to 600, or 400 to 700.
The 500 subheading on Mrs. Sri's card still reads clearly because it also differs from the body in two other ways, size and colour:
.subtitle {
font-weight: 500;
font-size: 0.875rem; /* 14px, smaller than the body */
color: #475569; /* grey, calmer than the body */
}
Remove the differences one at a time. Without the colour, the subheading still looks different. Without the size too, only the 100 step is left, and the subheading almost merges with the body.
One more thing: thin weights (300 and below) need large sizes. The thin lines of the letters at 14px are easy to lose, especially on a dim screen. Use Light only for text of 24px and up.
Font pairing: contrast, not conflict
If you want two fonts, pick ones with clearly different characters. The safest pair: a serif for headings, a sans-serif for the body. A serif font has small feet at the ends of the lines of each letter (Georgia, Times). A sans-serif font has none (Arial, Inter, system-ui). In CSS you write the pair with font-family, on .title (the heading) and on body (all the content of the page). The second name (serif, sans-serif) is a backup for when the first font is missing:
.title { font-family: Georgia, serif; } /* heading with feet */
body { font-family: system-ui, sans-serif; } /* body without feet */
- Two fonts that are similar but not the same, such as Verdana for headings and Arial for the body, look like a mistake rather than a choice.
- Common pairings: Inter for UI with Georgia for articles, or system-ui for an app with Merriweather for long content.
- Or simply 1 font with varied weights and sizes. Many modern apps use only one font family, and that is often enough.
⚠️ Weights that don't show up, and fonts that clash
- The weight isn't loaded. A web font (a font the browser downloads from the internet) only comes in the weights you load. If only weights 400 and 700 are loaded,
font-weight: 500shows as 400, and600shows as 700. The browser picks the nearest available weight, so your subheading quietly looks the same as the body. Check which weights you load. - Using every weight. Five or six weights on one page blur the hierarchy.
- Light on small text. 300 at 14px is hard to read.
- Two similar fonts. If two fonts differ, the difference must be clear. If you are not sure, use one font.
TL;DR: font-weight sets how heavy letters are, from 100 to 900: 400 = Regular (normal), 500 = Medium, 600 = Semibold, 700 = Bold (bold). 2 to 3 weights (levels of thickness) per website is enough, for example title 700, subheading 500, body 400. When weight is the only difference, jump at least 200, because 400 and 500 look almost the same. Light (300) is for large text only. For pairing (choosing two fonts to use together), choose contrast (two clearly different fonts), not conflict (two similar fonts): a serif (letters with small feet) for headings with a sans-serif (no feet) for the body, or a single font with varied weights. Make sure the weights you use are actually loaded (downloaded) by the browser.
⚡ A hierarchy from weight
Write:
<p class="title">Terrace Room</p>
<p class="subtitle">2 guests · queen bed · breakfast</p>
<p class="body">A first-floor room with a wooden terrace facing the potato garden.</p>
<style>
.title { font-weight: 700; } /* Bold: read first */
.subtitle { font-weight: 500; } /* Medium: supporting info */
.body { font-weight: 400; } /* Regular: the content */
</style>
Meaning: font-weight sets how heavy the letters are, from 100 to 900. On this room card, .title (the room name) is heaviest, so the eye catches it first. 400 is Regular (normal), 700 is Bold (bold). 2 to 3 weights (levels of thickness) per website is enough.
⚡ Jump at least 200
Guess first: a subheading at weight 500 and body text at weight 400, same size and same colour. Can you see the difference?
Barely. A step of 100 is hard to see when weight is the only difference.
Meaning: When only the weight differs, jump at least 200: 400 to 600, or 400 to 700. Light (thin, 300 and below) is for text of 24px and up only.
⚡ Pairing: contrast, not conflict
Write:
.title { font-family: Georgia, serif; } /* heading with feet */
body { font-family: system-ui, sans-serif; } /* body without feet */
Meaning: Font pairing means choosing two fonts to use together, and they must have clearly different characters: a serif (letters with small feet, such as Georgia) for headings, a sans-serif (no feet) for the body. font-family picks the font for .title (the heading) and body (all the content of the page). The second name (serif, sans-serif) is a backup for when the first font is missing. Two similar fonts, like Verdana and Arial, look like a mistake. Not sure? Use one font.