This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Google Fonts Embed Cheatsheet

A quick reference guide for embedding Google Fonts in web projects: HTML link tags, CSS @import rules, font weight variants, and combined stylesheets.

· Published

Google Fonts provides an open-source library of web typography ready for quick embedding in HTML and CSS.

Embed Methods

Place inside the <head> of your HTML document:

<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=Open+Sans:wght@400;700&display=swap" rel="stylesheet">

CSS @import

Include at the very top of your CSS stylesheet before any other rules:

/* Single font family with weights */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap');

/* Combining multiple font families */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Open+Sans:ital,wght@0,400;1,400&display=swap');

CSS Font Family Application

body {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

h1, h2, h3 {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
}

References

Related topics