Fonts

๐ŸŽจ CSS3+ ๐ŸŸข Chapter 16 of 49 ๐Ÿ“‚ Phase 06: Typography ๐Ÿ“… 2026 Edition
๐Ÿ“Œ Covered in this chapter: font-family ยท Generic Families ยท Web-Safe ยท Web Fonts ยท @font-face ยท Font Loading ยท Weight ยท Style ยท Stretch ยท Variable Fonts ยท Fallback ยท Performance
Welcome to Chapter 16: Fonts โ€” part of the CSS Complete Roadmap. This lesson covers all subtopics with clear explanations, code examples, and best practices used in professional web development.
1Font Family & Generic Font Families

font-family โ€” text render chese typeface stack. Browser first available font use chestundi left nundi right ki.

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

Generic families: serif, sans-serif, monospace, cursive, fantasy โ€” ultimate fallbacks.

2Web-Safe Fonts, Web Fonts & @font-face

Web-safe fonts: Arial, Georgia, Times โ€” system lo pre-installed. Web fonts โ€” custom files download avuthayi.

CSS โ€” @font-face
@font-face {
  font-family: 'CustomBrand';
  src: url('/fonts/custom-brand.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

font-display: swap โ€” text immediately visible with fallback, custom font load ayyaka swap avuthundi. Performance ki critical.

3Font Weight, Style, Stretch & Variable Fonts
CSS
.heading {
  font-weight: 700;
  font-style: normal;
}

.emphasis {
  font-weight: 600;
  font-style: italic;
}

.variable-heading {
  font-family: 'Inter', sans-serif;
  font-weight: 350;
  font-stretch: 95%;
}

Variable fonts โ€” single file lo weight, width, slant axes control. font-weight: 350 lanti fine values possible.

4Font Fallback & Performance
  • Always provide fallback stack ending with generic family
  • Use woff2 format โ€” best compression
  • Preload critical fonts: <link rel="preload" href="font.woff2" as="font" crossorigin>
  • Subset fonts โ€” only needed characters include cheyandi
  • Limit font families and weights โ€” each file HTTP request
OC
Written by Our Compiler Technical Editorial Team
Reviewed for accuracy ยท CSS Complete Roadmap ยท Last updated August 2026