Snelle referentie

Google Fonts Insluiten Spiekbriefje

Beknopte referentiegids voor het insluiten van Google Fonts in webprojecten: HTML link-tags, CSS @import-regels, letterdiktes en gecombineerde stylesheets.

· Gepubliceerd

Google Fonts biedt een open-sourcebibliotheek voor webtypografie die snel kan worden ingesloten in HTML en CSS.

Insluitmethoden

Plaats dit in de <head> van uw 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

Neem dit helemaal bovenaan uw CSS-stylesheet op vóór alle andere regels:

/* Enkele letterfamilie met gewichten */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap');

/* Meerdere letterfamilies combineren */
@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 Toepassing

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

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

Referenties

Verwante onderwerpen