How to install a custom font on an HTML site with CSS?

Spread the love

Sometimes, we want to install a custom font on an HTML site with CSS.

In this article, we’ll look at how to install a custom font on an HTML site with CSS.

How to install a custom font on an HTML site with CSS?

To install a custom font on an HTML site with CSS, we use the @font-face rule.

For instance, we write

@font-face {
  font-family: JuneBug;
  src: url("JUNEBUG.TTF");
}

h1 {
  font-family: JuneBug;
}

to add the @font-face rule to add the JuneBug font.

We set the src property to the URL of the font.

Then we use the font for h1 elements with font-family: JuneBug;.

Conclusion

To install a custom font on an HTML site with CSS, we use the @font-face rule.

Leave a Reply

Your email address will not be published. Required fields are marked *