Day 3: Typography: Fonts, Text & Google Fonts
✅ Today you will learn
- font-family and safe font stacks
- Google Fonts for English and Devanagari (Hindi)
- A type scale: font-size, weight and line-height
- letter-spacing, text-transform, text-align, text-decoration
- Readable paragraphs: line length and spacing
🏢 In the real world
95% of a website is text. A coaching institute owner sent this feedback: “Students say our notes page is tiring to read on the phone.” The fix was not new content – it was 18px text, 1.6 line-height, a 65-character line length and a proper Hindi font. Typography is the cheapest way to make a site feel premium.
font-family and font stacks
<style>
.serif { font-family: Georgia, "Times New Roman", serif; }
.sans { font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif; }
.mono { font-family: Consolas, "Courier New", monospace; }
.hand { font-family: "Comic Sans MS", cursive; }
</style>
<p class="serif">Serif – traditional, newspapers, wedding cards</p>
<p class="sans">Sans-serif – clean, modern, apps and websites</p>
<p class="mono">Monospace – code: print("Hello")</p>
<p class="hand">Cursive – only for decoration, never for paragraphs</p>The browser tries each font from left to right and uses the first one installed. Always end with a generic family (serif / sans-serif / monospace) so something sensible appears on every device.
Google Fonts – including Hindi
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&family=Noto+Sans+Devanagari:wght@400;600&display=swap" rel="stylesheet">
body {
font-family: "Poppins", system-ui, sans-serif;
}
:lang(hi) { /* any element with lang="hi" */
font-family: "Noto Sans Devanagari", "Poppins", sans-serif;
}| Good pairing | Headings | Body text |
|---|---|---|
| Modern business | Poppins 700 | Inter / system-ui 400 |
| Traditional (sweets, jewellery) | Playfair Display 700 | Lato 400 |
| Education | Nunito 800 | Nunito 400 |
| Hindi content | Noto Sans Devanagari 600 | Noto Sans Devanagari 400 / Hind |
Each font weight is a separate download (~20–40 KB). Load only the 2–3 weights you use, keep display=swap so text shows immediately, and never use more than two font families.
Size, weight and line height
<style>
html { font-size: 100%; } /* = 16px, respects user setting */
h1 { font-size: 2.25rem; font-weight: 800; line-height: 1.15; margin: 0 0 .5rem; }
h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.25; margin: 1rem 0 .4rem; }
p { font-size: 1.0625rem; line-height: 1.65; margin: 0 0 1rem; }
small { font-size: .875rem; color: #6b7280; }
</style>
<h1>Class 10 Science Notes</h1>
<small>Updated 25 Oct · 6 min read</small>
<h2>Chapter 1: Chemical Reactions</h2>
<p>A chemical reaction changes one or more substances into new substances. Signs of a reaction include a change in colour, release of gas, change in temperature and formation of a precipitate.</p>| Property | Typical value | Why |
|---|---|---|
| font-size (body) | 1rem–1.125rem (16–18px) | Below 16px is hard on phones |
| line-height (body) | 1.5–1.7 (no unit!) | Space between lines = less eye strain |
| line-height (headings) | 1.1–1.3 | Big text needs less gap |
| font-weight | 400 normal, 600 semi-bold, 700 bold | Only weights you loaded |
| max-width (paragraph) | 60–75ch | Long lines make eyes lose their place |
Text styling properties
<style>
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; font-weight: 700; color: #264de4; }
.title { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin: .2rem 0; }
.center { text-align: center; }
.strike { text-decoration: line-through; color: #9ca3af; }
.now { color: #16a34a; font-weight: 700; }
.fancy-link { color: #264de4; text-decoration: underline wavy #f59e0b; text-underline-offset: 4px; }
.truncate { width: 230px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px dashed #ccc; }
</style>
<div class="center">
<p class="eyebrow">Admissions open 2026–27</p>
<p class="title">Crack JEE with Vidya Coaching</p>
<p>Fee: <span class="strike">₹60,000</span> <span class="now">₹45,000</span></p>
<a class="fancy-link" href="#">See batch timings</a>
</div>
<p class="truncate">Very long product name: Premium Dry Fruit Gift Hamper with Kaju, Badam and Pista</p>Real fix: the tiring notes page
<style>
.before { font: 13px/1.2 Arial, sans-serif; text-align: justify; }
.after {
font-size: 1.0625rem;
line-height: 1.7;
max-width: 65ch;
color: #1f2937;
}
.label { font: 700 12px system-ui; color: #b91c1c; margin-top: 10px; }
.label.ok { color: #15803d; }
</style>
<p class="label">BEFORE</p>
<p class="before">Photosynthesis is the process by which green plants make their own food using sunlight, carbon dioxide and water. Chlorophyll in the leaves absorbs sunlight. Oxygen is released as a by-product, which is why plants are essential for life on Earth.</p>
<p class="label ok">AFTER</p>
<p class="after">Photosynthesis is the process by which green plants make their own food using sunlight, carbon dioxide and water. Chlorophyll in the leaves absorbs sunlight. Oxygen is released as a by-product, which is why plants are essential for life on Earth.</p>font: 600 1.125rem/1.6 "Poppins", sans-serif; sets weight, size, line-height and family in one line. Size and family are required; the order matters.
🏅 Job skills unlocked today
Practice tasks
🏋️ Practice – do it yourself
Show solution
Quick quiz
🧠 Quick Quiz – test yourself
Interview corner
💼 Interview Corner
Why should line-height usually be unitless?
A unitless value is a multiplier inherited as a ratio, so children with different font sizes get proportional spacing. A px or em value is computed once and inherited as a fixed length, causing cramped or huge gaps.
How do you keep web fonts fast?
Load few families and weights, use preconnect, font-display: swap, self-host WOFF2 files if possible, subset characters, and preload the main font file.
Summary
- Font stacks end with a generic family; load 2–3 Google Font weights.
- Use a Devanagari font for Hindi via :lang(hi).
- Body 1rem–1.125rem, line-height ~1.6, max-width ~65ch.
- letter-spacing, text-transform and text-overflow add polish.
Day 4: the box model – margin, padding, border, box-sizing and why your layout is 20px wider than expected.
