🇬🇧 Limited Time — UK Only·🎓 Free Learning for 1 Month·🤖 Free AI Training Included·📚 4,000+ Lessons · 35,000+ Quizzes·🏆 GCSE Mocks · Olympiad Papers·⚡ Selected Students Only · Limited Places·🎁 Free Value Worth £2,000·🇬🇧 Limited Time — UK Only·🎓 Free Learning for 1 Month·🤖 Free AI Training Included·📚 4,000+ Lessons · 35,000+ Quizzes·🏆 GCSE Mocks · Olympiad Papers·⚡ Selected Students Only · Limited Places·🎁 Free Value Worth £2,000·🇬🇧 Limited Time — UK Only·🎓 Free Learning for 1 Month·🤖 Free AI Training Included·📚 4,000+ Lessons · 35,000+ Quizzes·🏆 GCSE Mocks · Olympiad Papers·⚡ Selected Students Only · Limited Places·🎁 Free Value Worth £2,000·
🎨 CSS Styling

Text & Fonts

Typography is huge in design! CSS lets you control font-family (typeface), font-size, font-weight (bold), line-height (spacing between lines), text-align, and text-decoration (underline, strikethrough). Use Google Fonts by adding a link in HTML, then reference the font name in CSS.

3 min 10 XP Lesson 5 of 10
Text & Fonts
🌐

Appy Says…

Typography is 95% of web design. The right font makes an app feel premium, playful, or professional — and the wrong one makes it look amateur. CSS gives you full control over every aspect of text rendering.

📖

What are CSS Text and Font Properties?

CSS text properties control everything about how text looks: family, size, weight, line height, spacing, alignment, and decoration.

  • font-family: 'Inter', sans-serif;
  • font-size: 16px; / 1rem / 1.2em
  • font-weight: 400 | 700 | bold;
  • line-height: 1.6; (unitless ratio, relative to font-size)
  • letter-spacing: 0.05em;
  • text-align: left | center | right | justify;
  • text-decoration: none | underline;
  • text-transform: uppercase | capitalize;
  • Google Fonts: @import url('https://fonts.googleapis.com/...');
🎮

Think of it like Minecraft sign text

Minecraft signs let you write text but give no control over the font. CSS is the full font editor — change the typeface, size, spacing, weight, and colour on any text anywhere on your page.

⚙️

How It Works

  • 1. font-family lists fonts in priority order with a generic fallback: 'Poppins', 'Helvetica', sans-serif
  • 2. rem is relative to root font size (usually 16px) — better for accessibility
  • 3. em is relative to the element's own font-size
  • 4. line-height: 1.5 means 1.5× the font size — no unit needed
  • 5. Load Google Fonts: add @import at the top of CSS or <link> in HTML
  • 6. Variable fonts: one font file with axes for weight, width — modern and efficient
🌍

Real-World Examples

  • Apple's site uses San Francisco (system font) with precise letter-spacing
  • Medium uses Georgia serif for body text — increases readability for long articles
  • A heading: font-size: clamp(2rem, 5vw, 4rem); — fluid sizing across screen sizes
  • Brand logo text: font-weight: 800; letter-spacing: -0.03em; text-transform: uppercase;
💡

Key Facts

  • font-size: 1rem = browser default (usually 16px) — always use rem for accessibility
  • System font stack: font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif — fast, no download
  • FOUT (Flash of Unstyled Text) happens while web fonts load — use font-display: swap
  • Variable fonts can replace an entire font family with a single file
⚠️

Watch Out!

Never set a fixed pixel font size on the <html> element (e.g. font-size: 14px). This overrides users' browser accessibility settings. Use font-size: 100% or don't set it at all, then use rem everywhere else.

📌

Remember

Use rem for font sizes (accessibility-friendly). Set line-height: 1.5–1.7 for body text. Load Google Fonts with <link> in <head>.

What You Learned

  • font-family, font-size (rem), font-weight, line-height control text appearance
  • Use rem units; load Google Fonts with @import or
  • Unlocks: professional typography, brand identity, readable body text

Key Facts

  • font-size: 1rem = browser default (usually 16px) — always use rem for accessibility
  • System font stack: font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif — fast, no download
  • FOUT (Flash of Unstyled Text) happens while web fonts load — use font-display: swap
  • Variable fonts can replace an entire font family with a single file

Real-World Examples

• Apple's site uses San Francisco (system font) with precise <code>letter-spacing</code> • Medium uses Georgia serif for body text — increases readability for long articles • A heading: <code>font-size: clamp(2rem, 5vw, 4rem);</code> — fluid sizing across screen sizes • Brand logo text: <code>font-weight: 800; letter-spacing: -0.03em; text-transform: uppercase;</code>

Remember

Use rem for font sizes (accessibility-friendly). Set line-height: 1.5–1.7 for body text. Load Google Fonts with <link> in <head>.

Quick Quiz

1 / 2

Which property sets the typeface?