Summary

A practical CSS typography tutorial covering font classification, loading web fonts (Google Fonts, @font-face), fallback font stacks, and the key CSS properties for controlling text appearance. Part of a web development course on thedevspace.io.

CSS 排版教程,涵蓋字體分類、載入 Web 字體(Google Fonts、@font-face)、備用字體堆疊和控制文本外觀的關鍵 CSS 屬性。thedevspace.io Web 開發課程的一部分。

Key Points

  • Five font categories: Serif (Times New Roman, Georgia), Sans-serif (Arial, Helvetica), Monospace (Courier New), Cursive/Handwritten (Comic Sans), Display/Fantasy (Impact, Lobster)
  • Google Fonts integration: copy <link> tags into <head> or @import into CSS; then use as regular font-family
  • Local fonts: loaded with @font-face rule; prefer .woff2 format (best compression) as first option, fallback to .woff/.otf/.ttf
  • Fallback font stack: list fonts comma-separated in font-family; start with preferred, end with common system fonts and a generic family (serif, sans-serif, monospace)
  • CSS font properties: font-family, font-size, font-style (italic), font-weight, etc.
  • CSS text properties: letter-spacing, text-align, text-decoration-line, line-height, etc.

Insights

The .woff2 format tip (put it first in @font-face src list) is the practical decision that matters most for performance. Font fallback stacks are an often-neglected resilience concern: if the primary font fails to load, the fallback chain determines the visual impact. The standard pattern (preferred → common platform fonts → generic family) is worth knowing as a template. This article is a beginner-level reference rather than deep typography theory — useful for lookup but not for understanding principles like line rhythm, type scales, or optical sizing.

Connections

Raw Excerpt

Typography in CSS includes text decoration, font selection, sizing, spacing, alignment, and more, all of which contribute to a better user experience. Among these options, .woff2 is the preferred web font format, so make sure it is the first option.