How to import Google Fonts in HTML ?

Choosing the right font for your webpage is a very important aspect of any design. Using a web font service enables you to use a wide variety of fonts fit for presenting the data in your webpage. Google Fonts is a free web font service which hosts a huge variety of fonts to choose from. We can use these fonts in our webpages.

To use a custom font, we need to import the font family from the web font service, Google Fonts, in this case.

Method-1: Using <link> tag

<link href=’https://fonts.googleapis.com/css?family=Sofia’ rel=’stylesheet’/>

Method-2: Using @import rule

@import url(‘https://fonts.googleapis.com/css?family=Poppins’);

Example-1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<html>
  
<head>
    <link href=
          rel='stylesheet' />
    <style>
        h1 {
            font-family: Sofia;
            color: green;
        }
    </style>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
    </center>
</body>
  
</html>

chevron_right


Output:

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<html>
  
<head>
    <style>
        @import url(
        h1 {
            font-family: 'Open Sans', serif;
            color: green;
        }
    </style>
</head>
  
<body>
    <center>
        <h1>
GeeksforGeeks</h1>
    </center>
</body>
  
</html>

chevron_right


Output:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.