Search code examples
cssfontsfont-facewebfontstruetype

Can I use .otf or .ttf extension fonts for @font-face property in CSS?


@font-face{
  font-family: myriad;
  src: url(myriadpro.ttf);
  }

Can anyone tell me which extensions are valid for its usage like this?


Solution

  • You can use all font file format like this:

    @font-face {
      font-family: 'MyWebFont';
      src: url('webfont.eot'); /* IE9 Compat Modes */
      src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
           url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
           url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
           url('webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
           url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
    }