Free tutorials & notes in Hindi & English · Clean code examples 🧰 Free PDF & Image Tools →
🎨 Days 1–6 – CSS Foundations  ·  Day 03

Day 3: Typography: Fonts, Text & Google Fonts

⏱ 75 min📶 Beginner🎯 100% self-study
Day 3 / 20

✅ 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

HTML + CSS
<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>
▶  Generic families: serif, sans-serif, monospace, cursive
🧠 What is a font stack?

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

HTML – add in &lt;head&gt; before your style.css
<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">
CSS – use them
body {
  font-family: "Poppins", system-ui, sans-serif;
}
:lang(hi) {                       /* any element with lang="hi" */
  font-family: "Noto Sans Devanagari", "Poppins", sans-serif;
}
Good pairingHeadingsBody text
Modern businessPoppins 700Inter / system-ui 400
Traditional (sweets, jewellery)Playfair Display 700Lato 400
EducationNunito 800Nunito 400
Hindi contentNoto Sans Devanagari 600Noto Sans Devanagari 400 / Hind
⚠️ Performance

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

HTML + CSS
<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>
▶  A simple type scale: big tight headings, comfortable body
PropertyTypical valueWhy
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.3Big text needs less gap
font-weight400 normal, 600 semi-bold, 700 boldOnly weights you loaded
max-width (paragraph)60–75chLong lines make eyes lose their place

Text styling properties

HTML + CSS
<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>
▶  Eyebrow text, negative letter-spacing, strike prices, ellipsis

Real fix: the tiring notes page

HTML + CSS
<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>
▶  Same text – which would you rather read for an hour?
💡 The shorthand

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

✔ Write safe font stacks and load Google Fonts✔ Style Hindi text with a proper Devanagari font✔ Build a type scale with rem and unitless line-height✔ Make long text comfortable to read

Practice tasks

🏋️ Practice – do it yourself

Task 1: Style a price tag: small uppercase “MRP” label, crossed-out old price and big green new price.
Show solution
▶  Result
Task 2: Write a blog article style: h1 2.25rem, paragraphs 1.0625rem / 1.7, max-width 65ch, centred on the page with margin: 0 auto.
Task 3: Load Noto Sans Devanagari and show one English and one Hindi paragraph with the correct fonts using :lang(hi).

Quick quiz

🧠 Quick Quiz – test yourself

1. Why end a font stack with sans-serif?
Generic family always resolves.
2. Best body line-height?
Unitless 1.5–1.7.
3. Comfortable paragraph width?
60–75 characters.
4. Which shows “…” when text overflows one line?
All three needed.
5. display=swap in a Google Fonts URL…
Better perceived speed.

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.
➡️ Next

Day 4: the box model – margin, padding, border, box-sizing and why your layout is 20px wider than expected.

Frequently Asked Questions

Are Google Fonts free for commercial websites?
Yes, they are open-source (mostly SIL Open Font License) and free for client and commercial work.
Why does my Hindi text look broken?
The chosen font has no Devanagari glyphs, so the browser mixes fonts. Add a Devanagari font such as Noto Sans Devanagari or Hind for lang="hi" content.
← CSS (20 Days)
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

Next topicDay 4: The Box Model: Margin, Padding, Border Your progress: 3 / 20 (15%) · Lesson 4 / 20 Continue →

How was this lesson?

Your feedback helps us make the content better.

Write a review or suggestion (optional)

After approval, your name and city may appear publicly with your review. Please do not write your email or phone number.

▶ CodingEasily on YouTube

Learn with video lessons in easy Hindi

Featured video: RDBMS Part 3 – Class XI Commerce IT

▶ Subscribe – it’s free