Correct MIME types for webfonts?

For technical support and bug reports for all editions of CSS HTML Validator, including htmlval for Linux and Mac.
TomHTML
Rank III - Intermediate
Posts: 75
Joined: Sun Feb 04, 2018 10:19 am

Correct MIME types for webfonts?

Post by TomHTML »

I had been receiving an error from the validator on the correct mime type to receive for WOFF2 fonts. My server was sending out mime types following this prescription in my .htaccess file:

Code: Select all

AddType application/x-font-ttf           ttc ttf
AddType application/x-font-otf           otf
AddType application/font-woff            woff
AddType application/font-woff2           woff2
AddType application/vnd.ms-fontobject    eot
It follows the prescription I had adopted from a boilerplate .htaccess file several years ago. But researching the matter a bit, it seems the validator is right, as the proposed change to woff and woff2 in their mime types are found here:

https://dev.w3.org/webfonts/WOFF2/spec/#IMT

https://dev.w3.org/webfonts/WOFF/spec/#appendix-b

But this is still a bit vague to me. Could you provide a link to (or simple listing of) the precise mime types that should be reported for the standard collection of webfonts? (woff, woff2, eot, ttf, svg, otf). (Perhaps that's already been listed in another posting on the forum...my apologies if it has.)

Many thanks!
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX

Re: Correct MIME types for webfonts?

Post by Albert Wiersch »

Hello,

Here is a good list of all MIME types:
https://www.iana.org/assignments/media- ... ypes.xhtml

And the font types are here:
https://www.iana.org/assignments/media- ... xhtml#font

Code: Select all

Name 	Template 	Reference
----    -----------     ---------
otf	font/otf	[RFC8081]
sfnt	font/sfnt	[RFC8081]
ttf	font/ttf	[RFC8081]
woff	font/woff	[RFC8081]
woff2	font/woff2	[RFC8081]
The "application/vnd.ms-fontobject" type is on the list but the other fonts are "font/*" types.

The above is what CSS HTML Validator goes by.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
TomHTML
Rank III - Intermediate
Posts: 75
Joined: Sun Feb 04, 2018 10:19 am

Re: Correct MIME types for webfonts?

Post by TomHTML »

Thank you! That is very helpful!