What Google Fonts is, and why to use it
Google Fonts is a free library of open-source fonts you can drop into any website with a
single <link> tag. No licensing, no hosting, no font files
to download — just a URL that streams exactly the weights and characters you need.
Three ways to include a font
Pick one. The <link> version is the easiest and is what Google
recommends. Use @import when you can't edit the HTML head
(e.g. inside a CMS-managed stylesheet).
<!-- Inside <head> — the recommended way -->
<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=Inter:wght@400;700&display=swap"
rel="stylesheet">/* At the top of your stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');/* Then use it anywhere */
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
h1 {
font-family: 'Inter', sans-serif;
font-weight: 700;
}sans-serif or
serif at the end ensures text stays readable no matter what.
Add a Google Font to your page — step by step
Follow these 8 steps in order. You'll go from a blank page to a site using a custom font in about 3 minutes. Copy each snippet and paste it into your own file as you go.
Go to fonts.google.com and pick a font
Open fonts.google.com . Use the search bar or filters to find one you like. For this walkthrough we'll use Inter — a clean, modern sans-serif that works for almost anything.
Click into the font & select the weights you need
On the font's page, scroll down to the "Styles" section. Click + Get this font on Regular (400) and Bold (700). Those two cover 95% of websites — body text + headings. Skip the rest unless you know you'll use them.
Click "Get embed code" in the top-right sidebar
Once you've selected weights, a cart icon appears top-right. Click it, then click Get embed code. Google gives you two options: <link> (for HTML) and @import (for CSS). Choose <link>.
<link>: it loads faster than @import because browsers can download it in parallel with your CSS. Only use @import when you literally can't edit the HTML head.Copy the three lines Google shows you
You'll see three <link> tags. The first two are
preconnect hints that speed up loading. The third is the actual font.
Copy all three.
<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=Inter:wght@400;700&display=swap" rel="stylesheet">
Paste them inside your <head>
Open your index.html (or whatever your main HTML file is
called). Paste the three lines above between the opening
<head> tag and your existing
<link rel="stylesheet"> for your own CSS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My site</title>
<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=Inter:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
</head>
font-family.Use the font in your CSS
Open styles.css (or whatever your stylesheet is called).
Add font-family rules using the font name Google gave you.
Wrap it in single quotes.
/* styles.css */ body { font-family: 'Inter', sans-serif; font-size: 16px; line-height: 1.6; } h1, h2, h3 { font-family: 'Inter', sans-serif; font-weight: 700; }
'Playfair Display', 'Roboto Mono') break without quotes. Single-word ones (Inter) work either way, but quoting everything is a safe habit.Always add a fallback font at the end
If Google Fonts fails (bad wifi, ad blocker, offline), the browser falls back down
the stack. Adding sans-serif or serif
at the end guarantees your text always renders in something readable.
body {
/* Good — with fallbacks */
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
/* Bad — no fallback. If Google Fonts fails, text is unstyled. */
body {
font-family: 'Inter';
}
-apple-system, BlinkMacSystemFont falls back to the device's native UI font (San Francisco on Mac/iOS, Segoe on Windows). Users don't even notice the swap.Save both files and reload your browser
Save index.html and styles.css.
Hard-reload your browser tab (Cmd/Ctrl + Shift + R). Your
page should now render in Inter.
fonts.googleapis.com returning 200. If it's 404, the family name in the URL is misspelled.Done — your site now uses a custom font 🎨
From here, experiment with heavier weights, italics, or mixing two fonts (one for headings, one for body). The rest of this tutorial covers which fonts pair well and how to load multiple families efficiently.
--font-display: 'Playfair Display', serif; — then swap fonts globally by changing one line.A tour of 8 great Google Fonts
Every font below is loaded on this page. Hover to see them come alive — these are all production-tested choices you can use today.
Loading only the weights you need
Every weight you request is more bytes to download. The URL parameter
:wght@400;700 tells Google Fonts to send just the 400 and 700
weights — typically all you need for body text + headings.
All 9 weights of Inter, side by side
Requesting multiple families + weights
Chain families with &family=. Add italics with
ital,wght@.
<link href="https://fonts.googleapis.com/css2? family=Inter:wght@400;600;800 &family=Playfair+Display:ital,wght@0,700;1,400 &family=Roboto+Mono:wght@400;700 &display=swap" rel="stylesheet">
family=Inter:wght@400;600;800
→ Inter at weights 400, 600, 800
&family=Playfair+Display:ital,wght@0,700;1,400
→ Playfair Display — roman 700 (0,700) + italic 400 (1,400)
&family=Roboto+Mono:wght@400;700
→ Roboto Mono at weights 400, 700
&display=swap
→ Show fallback font first, swap when Google font loads
(prevents invisible text while loading)Pairing fonts that just work
A classic formula: use a display font for headings and a neutral sans-serif for body. Contrast is good — sameness is boring.
Cities of the sky
Nairobi at dawn has a particular silver quality to it, as if the moon had spent the night dusting every windshield, every rooftop, every fence.
Ship faster, learn louder.
Our platform helps engineering teams go from commit to production in under 90 seconds, with automatic rollbacks, feature flags, and instant previews baked in.
LIMITED EDITION
Only 500 pieces. Hand-assembled in Berlin. Ships in a felt-lined walnut case with a lifetime warranty card.
The last bookshop on Flatbush.
It took Marianne nineteen years to figure out what the store was for. Her grandmother had never told her. Her father had gestured vaguely at the shelves and said, "you'll know."
Try it — live font playground
Pick a font, weight, and size. See how your text would look before you commit to anything.
Typography rules
Do
- Use 1–2 font families per page
- Load only the weights you actually use
- Always add
display=swapto prevent invisible text - Include a system font fallback at the end of the stack
- Preconnect to
fonts.gstatic.comfor speed - Use 16px+ for body text on mobile
- Keep line length 50–75 characters
- Pair a display font with a neutral body font
Don't
- Load 8 different font families on one page
- Request every weight (100–900) "just in case"
- Use decorative script fonts for body copy
- Forget the fallback — dropped connections happen
- Set body text below 14px — it hurts readability
- Pair two similar sans-serifs — no contrast
- Use lowercase text in a font designed for ALL CAPS
- Forget to test how fonts render on Windows vs. Mac
The complete starter snippet
Copy this into any HTML project and you have a professional typography foundation with zero config.
<head>
<!-- Speed up Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Load Inter (400 + 700) and Playfair Display (700) -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=Playfair+Display:wght@700&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="styles.css">
</head>/* styles.css */
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
font-size: 16px;
line-height: 1.6;
color: #111;
}
h1, h2, h3 {
font-family: 'Playfair Display', Georgia, serif;
font-weight: 700;
line-height: 1.2;
letter-spacing: -0.02em;
}
/* Tabular numbers for stats / prices */
.stat { font-variant-numeric: tabular-nums; font-weight: 700; }