Aral Code

Text & Content Lesson 11 of 33

CSS Fonts — Family, Size, Weight and Google Fonts

Choose fonts with font-family and fallbacks, set sizes and weights, use the font shorthand, and add free Google Fonts to your website.

The font you choose sets the mood of a whole website. A rounded font feels friendly, a serif font feels formal or traditional, and a monospace font feels technical. In this lesson you'll learn to choose fonts and control their size and weight.

font-family

font-family sets the typeface. You always give a list of fonts, called a font stack, separated by commas:

body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

The browser tries the first font. If the visitor's device doesn't have it, it tries the next one, and so on. The last item should always be a generic family, which every device has.

The generic families

Example Generic font families
<style>
  p { font-size: 22px; margin: 8px 0; }
</style>
<p style="font-family: serif;">serif — Kumusta ka? (small "feet" on letters)</p>
<p style="font-family: sans-serif;">sans-serif — Kumusta ka? (clean, no feet)</p>
<p style="font-family: monospace;">monospace — Kumusta ka? (equal width)</p>
<p style="font-family: cursive;">cursive — Kumusta ka? (handwriting style)</p>
  • serif (like Times New Roman, Georgia) — traditional, used in newspapers and books
  • sans-serif (like Arial, Helvetica, Roboto) — modern and clean, the most common choice for websites
  • monospace (like Courier, Consolas) — every letter the same width, used for code

font-size

Sets the size of the text. The common units:

  • px — pixels, a fixed size. Easy to understand.
  • rem — relative to the root (html) font size, usually 16px. 1.5rem = 24px. Respects the user's browser settings.
  • em — relative to the parent's font size.
  • % — percentage of the parent's font size.
Example Font sizes
<style>
  body { font-family: Arial, sans-serif; }
</style>
<p style="font-size: 12px;">12px — fine print, too small for phones</p>
<p style="font-size: 16px;">16px — normal body text (1rem)</p>
<p style="font-size: 1.5rem;">1.5rem — 24px, a subheading</p>
<p style="font-size: 2.5rem;">2.5rem — a big title</p>

font-weight

How thick the letters are. Use normal, bold, or numbers from 100 (thin) to 900 (black), where 400 is normal and 700 is bold.

Example Font weights
<style>
  p { font-family: system-ui, sans-serif; font-size: 20px; margin: 4px 0; }
</style>
<p style="font-weight: 300;">300 — Light</p>
<p style="font-weight: 400;">400 — Normal</p>
<p style="font-weight: 600;">600 — Semi-bold</p>
<p style="font-weight: 800;">800 — Extra bold</p>

Not every font has every weight. If a weight isn't available, the browser picks the closest one, so 300 and 400 might look the same on some devices.

font-style

font-style: italic; makes text slanted, and normal removes italics (for example, from an <em> you want to look different).

The font shorthand

font combines several properties in one line. The size and family are required, in that order, at the end:

/* style  weight  size/line-height  family */
p { font: italic 700 18px/1.6 Georgia, serif; }

It's compact, but beginners often find the longhand easier to read and edit. Both are fine.

Web fonts: Google Fonts

To use a font that visitors might not have, you can load it from the web. Google Fonts (fonts.google.com) offers more than 1,500 free fonts. Steps:

  1. Go to fonts.google.com and pick a font, for example Poppins.
  2. Choose the weights you need (keep it to 2 or 3 — each weight is another download).
  3. Copy the <link> code Google gives you into your page's <head>.
  4. Use the font name in your CSS.
<head>
  <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=Poppins:wght@400;700&display=swap" rel="stylesheet">
</head>
body {
  font-family: "Poppins", Arial, sans-serif;
}

Keep Arial, sans-serif at the end as a fallback, in case the font hasn't loaded yet or the connection is slow.

Example A page with a Google Font
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap" rel="stylesheet">
<style>
  body { font-family: "Poppins", Arial, sans-serif; }
  h1 { font-weight: 700; color: #0f5c4d; margin-bottom: 4px; }
</style>
<h1>Bakery ni Mang Ben</h1>
<p>Fresh pandesal, ensaymada and spanish bread every morning.</p>

Choosing fonts: simple rules

  • Use one or two fonts per website. One for headings and one for body text is plenty.
  • Body text must be easy to read. Save decorative or script fonts for a logo or big title only.
  • Mind the data. Each font and weight is a download. System fonts like system-ui load instantly and cost no data.
  • Check Filipino text. Make sure the font includes ñ. Most do, but some decorative fonts don't.

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. Why should a font stack end with a generic family like sans-serif?
2. Which font-weight value is the same as bold?
3. How do you write a font name that has spaces?
4. What is a good minimum font size for body text on phones?

By Sir Reyel · Last updated 2026-12-04