Using Google Fonts
What are Google Fonts?
Google Fonts is a free library of over 1,400 fonts that you can use on your website. They're optimized for the web, easy to use, and completely free.
How to Add Google Fonts
There are two ways to add Google Fonts: using a <link>
tag in HTML or @import in CSS. The link method is recommended
for better performance.
<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@400;700&display=swap" rel="stylesheet">
Using the Font in CSS
Once you've added the link, use the font in your CSS with
font-family. Always include fallback fonts.
Popular Font Combinations
Pairing fonts effectively creates visual hierarchy. Here are some popular combinations:
Best Practices
- Limit fonts - Use 2-3 fonts maximum per website
- Load only needed weights - Don't load all 9 weights if you only use 2
- Use
font-display: swap- Shows fallback text while font loads - Preconnect - Add preconnect links for faster loading
- Always include fallbacks - System fonts as backup
Finding Fonts
Visit fonts.google.com to browse and select fonts. The site shows you exactly what code to add to your website.
Quick Quiz
What is the recommended way to add Google Fonts?
Enjoying these tutorials?