liveBook · Manning

Google Fonts

As explained in Tiny CSS Projects

Google Fonts is a hosted catalog and delivery service for open-source fonts used in websites and applications.

Google Fonts provides freely available fonts that websites can import and use without requiring visitors to create accounts. Importing a font lets the browser render its glyphs when the typeface is not already installed. section 4.1.1

Use Google Fonts thoughtfully in a stylesheet:

  • Import the selected family before the relevant CSS rules, then assign it with font-family. section 4.1.1
  • Always provide a fallback such as serif, sans-serif, monospace, cursive, or fantasy if the import fails. section 4.1.1
  • Combine multiple Google Fonts into one request when a design uses several families or weights. section 5.1
  • Review CDN privacy and data terms, including applicable GDPR and European Union requirements, before loading fonts remotely. section 4.1.1

Typography for a responsive newspaper

A newspaper layout imports PT Serif for body text and uses serif as its fallback. A second import adds Oswald in regular and bold weights for the title, which is enlarged, centered, capitalized, and displayed in a sans-serif fallback. The body typography then inherits across its descendants. section 4.1.1

Typography for summary cards

A card layout uses italic Cardo for descriptions and regular and bold Rubik for headings. The contrasting typefaces support readable, informal hotel cards while one request loads the required Google Fonts. section 5.1

Listing 4.2 Defining some theme styles
@import url('https:/ /fonts.googleapis.com/css2?family=PT+Serif&display=swap'); #1
 
body {
  background-color: #f9f7f1;
  font-family: 'PT Serif', serif;                                               #2
  color: #404040;
  padding: 0 24px;
}

Inspect the CSS listing to see a Google Fonts import placed before the body rule, followed by a font-family declaration with a serif fallback. section 4.1.1

How Tiny CSS Projects covers it

How deep it goes
Explains CSS importing, family selection, fallbacks, combined requests, and CDN cautions without covering font-loading internals.
Examples
Demonstrates PT Serif, Oswald, Cardo, and Rubik in newspaper and summary-card layouts.
What you can do after
Apply it via CSS imports, font-family declarations, fallbacks, and combined requests.
How it connects
Connects font-family, fallback fonts, CSS inheritance, content delivery networks, and responsive web design.

Also explained in

Compare how 4 books explain Google Fonts →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.