Coding/Learn/css/typography fonts
CSS Beginner Course
01.Introduction to CSS
02.Selectors (Element, Class & ID)
03.3 Ways to Add CSS to HTML
04.Colors & Backgrounds (HEX, RGB, HSL)
05.Typography & Fonts (font-size, font-weight, line-height)
06.The Cascade & Specificity Wars
07.The Sacred CSS Box Model
08.Padding vs Margin & Shorthand Notation
09.Borders & Border Radius (Rounded Corners & Circles)
10.The Magic of box-sizing: border-box
11.Sizing & Units (px, rem, em, %, vh, vw)
12.The Display Property (block, inline, inline-block, none)
13.Flexbox Part 1: Container Powers (justify, align, gap)
14.Flexbox Part 2: Direction, Wrapping & Item Powers
15.Positioning (relative, absolute, fixed, sticky)
16.Z-Index & The 3D Stacking Context
17.Pseudo-Classes (:hover, :active, :focus, :first-child)
18.Smooth Transitions & Box Shadows
19.Responsive Design & Media Queries (@media)
20.Capstone: Crafting a Modern UI Profile Card
Course Certificate0%

Complete all lessons to earn

LearnTypography & Fonts (font-size, font-weight, line-height)
5 / 20 0%
Lesson 05 of 20
5 mins read

Typography & Fonts (font-size, font-weight, line-height)

PreviousNext Lesson
In Plain English

Typography is 90% of web design. If your typography is clean, your site looks like an Apple product. If your typography is bad, your site looks like a scam. Master font-family, font-size, font-weight, and line-height.

The Mental Model

"font-size is the volume of your voice. font-weight is how firmly you lean into words (bold vs light). line-height is the breathing room between lines of text so sentences don't crash into each other like a multi-car pileup."

Deep Dive: How It Works

font-family: Sets the typeface (e.g. system-ui, Inter, JetBrains Mono). Always provide fallback fonts: font-family: Inter, sans-serif;.

font-size: Sets text size in px or rem (e.g. 16px, 1.25rem).

font-weight: Controls thickness: 400 (normal/regular), 600 (semibold), 700 (bold).

line-height: Controls vertical line spacing. For body paragraphs, 1.5 or 1.6 gives optimal readability.

letter-spacing: Controls tracking/spacing between characters (great for uppercase badges: letter-spacing: 0.05em;).

Syntax Blueprint

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
}

Modern clean system typography stack with optimal line height.

PointCore Rules to Remember

Point star
Generous Line Height: Always set line-height: 1.5 to 1.6 for body text to prevent eye fatigue.
Point star
Font Fallback Stacks: Always end your font-family list with a generic family like sans-serif or monospace.
Point star
Weight Scale: Use numbers like 400 (normal), 600 (semi-bold), 700 (bold).

Common Beginner Traps & How to Fix Them

Mistake:Using units like px on line-height

Why it happens: Writing line-height: 1.5px crushes all text into a single overlapping line.

How to fix: line-height is usually unitless (e.g. line-height: 1.6;) which multiplies by the font size automatically.

Pro Tip: Use text-transform: uppercase with letter-spacing: 0.08em on tiny badges for an ultra-premium aesthetic!

Live Interactive Example

Hit Run Code to see it live
High-End Editorial Typography
CSS3
1
2
3
4
5
6
7
8
9
10
11
12
13
Live Browser Preview
Click "Preview / Apply" to view the rendered output.
How it works: The tight letter spacing on h1 looks crisp while 1.6 line height makes paragraphs easy to read.

Your Turn: Micro Challenge

No pressure! Edit the starter code below and test your solution with instant feedback.

Micro Exercise

Style paragraph typography

  • PointWrite a CSS rule for p setting font-size: 16px; and line-height: 1.6;
1
2
Browser Preview & Output
Click "Run & Check" to test your solution.

Finished reading and practicing?

Mark this lesson as completed to update your course progress.

PreviousNext Lesson
Overview100 SheetLearnCertificates