cssfontsfont-facewebfonts

Why should we include ttf, eot, woff, svg,... in a font-face


In CSS3 font-face, there are multiple font types included like ttf, eot, woff, svg and cff.

Why should we use all of these types?

If they are special to different browsers, why is the number of them greater than the number of the major web browsers?


Solution

  • Answer in 2019:

    Only use WOFF2, or if you need legacy support, WOFF. Do not use any other format

    (svg and eot are dead formats, ttf and otf are full system fonts, and should not be used for web purposes)

    Original answer from 2012:

    In short, font-face is very old, but only recently has been supported by more than IE.

    If you don't want to support IE 8 and lower, and iOS 4 and lower, and android 4.3 or earlier, then you can just use WOFF (and WOFF2, a more highly compressed WOFF, for the newest browsers that support it.)

    @font-face {
      font-family: 'MyWebFont';
      src:  url('myfont.woff2') format('woff2'),
            url('myfont.woff') format('woff');
    }
    

    Support for woff can be checked at http://caniuse.com/woff
    Support for woff2 can be checked at http://caniuse.com/woff2