@font-face
Embed This Widget
Add the script tag and a data attribute to embed this widget.
Embed via iframe for maximum compatibility.
<iframe src="https://fontfyi.com/iframe/glossary/font-face/" width="420" height="400" frameborder="0" style="border:0;border-radius:10px;max-width:100%" loading="lazy"></iframe>
Paste this URL in WordPress, Medium, or any oEmbed-compatible platform.
https://fontfyi.com/glossary/font-face/
Add a dynamic SVG badge to your README or docs.
[](https://fontfyi.com/glossary/font-face/)
Use the native HTML custom element.
A CSS at-rule that allows web designers to specify custom fonts for their web pages. The foundation of web typography.
The @font-face at-rule is the CSS mechanism for loading custom fonts — it registers a font family name and associates it with a source file, so that name can be used throughout your stylesheet. Every custom web font, whether self-hosted or served by Google Fonts or Adobe Fonts, arrives in your CSS through @font-face declarations.
Basic syntax:
@font-face {
font-family: 'Inter';
src: url('/fonts/inter-regular.woff2') format('woff2');
font-weight: 400;
font-style: normal;
font-display: swap;
}
Multiple weights and styles:
Each weight and style variant requires its own @font-face declaration with the same font-family name. The browser matches font-weight and font-style descriptors to select the correct file:
@font-face {
font-family: 'Inter';
src: url('/fonts/inter-regular.woff2') format('woff2');
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Inter';
src: url('/fonts/inter-bold.woff2') format('woff2');
font-weight: 700;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Inter';
src: url('/fonts/inter-italic.woff2') format('woff2');
font-weight: 400;
font-style: italic;
font-display: swap;
}
Variable fonts — one declaration replaces many:
@font-face {
font-family: 'Inter';
src: url('/fonts/inter-variable.woff2') format('woff2-variations');
font-weight: 100 900; /* Declares a range */
font-style: normal;
font-display: swap;
}
The font-display descriptor controls FOUT/FOIT behavior:
| Value | Behavior |
|---|---|
auto |
Browser default (usually block) |
block |
Invisible text until font loads (FOIT) |
swap |
Fallback immediately, swap when loaded (FOUT) |
fallback |
100ms block, then swap if loads within 3s |
optional |
100ms block, browser decides whether to swap |
font-display: swap is recommended for most use cases. optional is appropriate when you'd rather the user see system fonts consistently than experience a layout shift.
Unicode range for conditional loading:
@font-face {
font-family: 'MyFont';
src: url('/fonts/myfont-latin.woff2') format('woff2');
unicode-range: U+0000-00FF;
}
The font-family name you declare in @font-face is scoped to your CSS — it doesn't need to match the font's actual name. font-family: 'MyBrandFont' pointing to Inter's files is perfectly valid, though it creates maintenance confusion. By convention, use the font's actual name.
Términos relacionados
Herramientas relacionadas
Fuentes que ilustran este concepto
Saber más
Una guía práctica sobre el uso de fuentes variables en CSS: carga, configuración de ejes, animación de propiedades y consideraciones de compatibilidad con navegadores.
Tipografía CSSAñade Google Fonts o fuentes personalizadas a Tailwind CSS: extendiendo el tema de font-family, cargando fuentes de forma eficiente y mejores prácticas para la tipografía de Tailwind.
Tipografía CSSAutoalojar Google Fonts te da control total sobre la carga, la privacidad y el almacenamiento en caché. Una guía paso a paso desde la descarga hasta el despliegue.
Tipografía CSSUn tutorial paso a paso sobre el uso de @font-face en CSS para cargar fuentes personalizadas: sintaxis, selección de formato y ejemplos prácticos que puedes copiar y pegar.