15 of 313 menu

The font-face command

The @font-face command allows you to specify a custom font, the source of which is stored in a file. This font can then be connected using the font-family property.

Syntax

@font-face { font name; font search source; }

Example

Let's find a font on our local computer:

<body> This is Montserrat SemiBold. </body> @font-face { font-family: "Montserrat SemiBold"; src: local("Montserrat SemiBold"); } body { font-family: "Montserrat SemiBold"; } #elem { animation: anim 3s infinite; border: 1px solid black; width: 50px; height: 50px; }

:

Example

Now let’s specify the url of the remote server to search for the font:

<body> This is Bitstream Vera Serif Bold. </body> @font-face { font-family: "Bitstream Vera Serif Bold"; src: url("https://mdn.github.io/css-examples/web-fonts/VeraSeBd.ttf"); } body { font-family: "Bitstream Vera Serif Bold", serif; } #elem { animation: anim 3s infinite; border: 1px solid black; width: 50px; height: 50px; }

:

idcsfrdeby