-1

I can't get the Roboto font to work in my HTML file. If I understand correctly, Google's instruction are:

"Copy these lines into your head tag":

<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@100&display=swap" rel="stylesheet">

This is my HTML:

<!DOCTYPE html>
<html>
<head>
    <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@100&display=swap" rel="stylesheet">
</head>
<body>
    <h3>This is a heading</h3>
    <p>This is a string.</p>
</body>
</html>

Instead of the Roboto font, the website shows the standard font:

enter image description here

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Artur Müller Romanov
  • 4,417
  • 10
  • 73
  • 132

2 Answers2

1

add this before </head>

<style>
body {
  font-family: "Roboto", sans-serif;
}
</style>
heysujal
  • 118
  • 7
0

You did not use font family in css, use like this

<style>
body, h1,h2,h3,h4,h5,h6,p {
  font-family: "Roboto", sans-serif;
}
</style>