liveBook · Manning

Font

As explained in CSS in Depth, Second Edition

A font is a specific typeface variant defined by characteristics such as weight, style, or width.

A font is a specific variant within a typeface, distinguished by characteristics such as weight or style. Choosing the right font changes both a page’s visual tone and its readability. section 12.3 section 12.2

Use fonts deliberately when building a page:

  • Prefer web fonts when the design depends on a typeface that users may not have installed; use @font-face or a font service to make it available. section 12.2
  • Select the required weights and styles rather than assuming every typeface provides the same range. Numeric weights can include 100, 400, 700, and 900. section 12.3
  • Assign complementary fonts to different roles, such as Roboto for body text and Sansita for headings and navigation. section 12.3
  • Check thin fonts more carefully: identical colors can produce weaker perceived contrast when the weight is very light. section 11.4

Applying selected web fonts

Load the selected families with the generated stylesheet link, then assign them by role: body { font-family: Roboto, sans-serif; } h1, h2, h3, h4 { font-family: Sansita, serif; } .home-link { font-family: Sansita, serif; font-weight: bold; } section 12.3 section 12.3

Listing 12.6 Stylesheet <link> tags for Google Fonts
<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=Roboto:wght@300&family=Sansita:wght@800&display=swap"
  rel="stylesheet"
/>

Use the stylesheet-link listing to inspect how selected Google Fonts are embedded with specific families and weights. section 12.3

How CSS in Depth, Second Edition covers it

How deep it goes
Explains font families, weights, styles, web-font delivery, role-based CSS, and perceived contrast without detailing font-file internals.
Examples
Uses Google Fonts, Sansita, Roboto, generated stylesheet links, role-based CSS declarations, and thin Helvetica Neue contrast comparisons.
What it assumes
Assumes basic CSS declarations and distinguishes typeface families from their individual font variants.
What you can do after
Apply fonts via Google Fonts and CSS, selecting families, weights, styles, fallbacks, and readable text colors.
How it connects
Connects fonts with typefaces, web fonts, CSS font-family, font-weight, @font-face, fallback fonts, and color contrast.

Also explained in

Compare how 6 books explain font →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.