liveBook · Manning

Web font

As explained in Web Design Playground, Second Edition

A web font is a font made available to a web page through web resources rather than requiring installation on the user's device.

A web font is a font file hosted on the web and loaded by a page through CSS, so visitors can see the intended typeface without installing it. The @font-face rule tells the browser where to find the files. Unlike system fonts, web fonts make the page’s typography more predictable across devices. section 18.2

Choose where the font files live:

  • Use a third-party host such as Google Fonts, Fonts.com, or Adobe Fonts. These services generally handle font licensing and hosting, making setup easier. section 18.3
  • Host the font files on your own site. This avoids relying on a remote font server, but requires managing the files and permissions yourself. section 18.2
  • Remember the trade-off: remote fonts may add loading time, especially when many font files are linked, although major services optimize delivery. section 18.3

Load and apply a hosted font

Select the typeface and styles you need on the font host, copy its generated link tags into the page head before your own stylesheet, then apply the font in CSS. For example, load Lato and use it with a sans-serif fallback: p { font-family: Lato, sans-serif; } section 18.3

&lt;link rel=&quot;preconnect&quot; href=&quot;<a class="urlb" href="https://fonts.googleapis.com">https://fonts.googleapis.com</a>&quot;&gt;
&lt;link rel=&quot;preconnect&quot; href=&quot;<a class="urlb" href="https://fonts.gstatic.com">https://fonts.gstatic.com</a>&quot; crossorigin&gt;
&lt;link href=&quot;<a class="urlb" href="https://fonts.googleapis.com/css2?family=Lato">https://fonts.googleapis.com/css2?family=Lato</a>:ital,wght@0,400;1,400;1,700&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;

Inspect the generated link tags that connect a page to Google Fonts and request regular, italic, and bold styles. section 18.3

How Web Design Playground, Second Edition covers it

How deep it goes
Defines hosted font files, explains @font-face and hosting choices, and demonstrates third-party setup without detailing custom file hosting.
Examples
Demonstrates Google Fonts link tags and applies Lato through a CSS font-family declaration.
What it assumes
Builds from familiarity with system fonts and font stacks while defining web fonts and hosted-font loading directly.
What you can do after
Apply it via Google Fonts by linking selected styles in HTML and assigning the hosted typeface in CSS.
How it connects
Connects web fonts with typography, font stacks, system fonts, CSS, HTML link elements, and font licensing.

Also explained in

Compare how 3 books explain web font →

Related concepts

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