How to include a font .ttf using CSS?

Spread the love

Sometimes, we want to include a font .ttf using CSS.

In this article, we’ll look at how to include a font .ttf using CSS.

How to include a font .ttf using CSS?

To include a font .ttf using CSS, we set the src property.

For instance, we write

@font-face {
  font-family: "MyWebFont";
  src: url("webfont.eot");
  src: url("webfont.eot?#iefix") format("embedded-opentype"),
    url("webfont.woff") format("woff"), url("webfont.ttf") format("truetype"),
    url("webfont.svg#svgFontName") format("svg");
}

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

font-family is set to the font name.

And we set the src property to the font’s URL.

Conclusion

To include a font .ttf using CSS, we set the src property.

Leave a Reply

Your email address will not be published.