htmlfonts
← Back to Guides Directory
Asset Hosting

How to Use Custom Fonts in CSS

01. The Concept

The @font-face rule allows you to host your own typography files. Always serve modern formats like WOFF2 for maximum compression and fast loading.

02. Production-Ready Code

@font-face { font-family: 'MyBrandFont'; src: url('/fonts/myfont.woff2') format('woff2'); font-display: swap; }

💡 Pro Typography Tip

Always include a web-safe fallback stack to prevent invisible text during loading.