Specifying Style and Weight for Google Fonts

They use regular CSS.

Just use your regular font family like this:

font-family: 'Open Sans', sans-serif;

Now you decide what “weight” the font should have by adding

for semi-bold

font-weight:600;

for bold (700)

font-weight:bold;

for extra bold (800)

font-weight:800;

Like this its fallback proof, so if the google font should “fail” your backup font Arial/Helvetica(Sans-serif) use the same weight as the google font.

Pretty smart 🙂

Note that the different font weights have to be specifically imported via the link tag url (family query param of the google font url) in the header.

For example the following link will include both weights 400 and 700:

<link href="https://stackoverflow.com/questions/7256065/fonts.googleapis.com/css?family=Comfortaa:400,700"; rel="stylesheet" type="text/css">

For CSS2

<link href="https://stackoverflow.com/questions/7256065/fonts.googleapis.com/css2?family=Comfortaa:wght@400;700"; rel="stylesheet" type="text/css">

Leave a Comment