Font MIME Types — WOFF, WOFF2, TTF, OTF
Learn the correct MIME types for web fonts including font/woff2, font/woff, font/ttf, and font/otf, plus server configuration tips.
Detailed Explanation
Web Font MIME Types
Serving fonts with the correct MIME type is essential for browser rendering, CORS compliance, and HTTP/2 prioritization.
Official Font MIME Types (RFC 8081)
| MIME Type | Extension | Format | Recommended |
|---|---|---|---|
font/woff2 |
.woff2 | WOFF 2.0 | Yes (best compression) |
font/woff |
.woff | WOFF 1.0 | Fallback |
font/ttf |
.ttf | TrueType | Legacy fallback |
font/otf |
.otf | OpenType | Legacy fallback |
application/vnd.ms-fontobject |
.eot | EOT | IE only (deprecated) |
Why WOFF2 First
WOFF2 uses Brotli compression and achieves 30–50% smaller file sizes compared to WOFF 1.0. All modern browsers support it.
CSS @font-face
@font-face {
font-family: "MyFont";
src: url("myfont.woff2") format("woff2"),
url("myfont.woff") format("woff"),
url("myfont.ttf") format("truetype");
font-display: swap;
}
Server Configuration
Many servers default to application/octet-stream for font files. Add explicit types:
# Nginx
types {
font/woff2 woff2;
font/woff woff;
font/ttf ttf;
font/otf otf;
}
CORS for Fonts
Fonts loaded cross-origin require CORS headers:
Access-Control-Allow-Origin: *
Without this, browsers block the font and fall back to a system font.
Performance Tips
- Use
font-display: swapto avoid invisible text - Subset fonts to include only needed characters
- Preload critical fonts with
<link rel="preload"> - Self-host rather than using Google Fonts for privacy and performance
Use Case
Apply these MIME types when configuring web servers, CDNs, or build tools to serve custom fonts. Use font/woff2 as the primary format and add CORS headers for cross-origin font loading.
Try It — MIME Type Reference
Related Topics
text/css and text/javascript — Serving Web Assets Correctly
Best Practices
image/jpeg vs image/png — Choosing the Right Image Format
Image Types
Choosing the Right Content-Type for REST APIs
Application Types
application/octet-stream — The Generic Binary Fallback
Common Types
image/svg+xml — Scalable Vector Graphics on the Web
Image Types