CSS Font Face "?#iefix"

21,015

It's because of the way IE8 and below interpret font declarations. The normal url('myfont-webfont.eot') would lead to 404 Server errors in these versions of IE; adding the ?#iefix fixes the server issues. (It's for the same reason there's conditional stylesheets for IE.)

According to Fontspring (straight from the source):

Internet Explorer <9 has a bug in the parser for the src attribute. If you include more than one font format in the src, IE fails to load it and reports a 404 error. The reason is that IE attempts to load as a file everything between the opening parenthesis all the way to the very last closing parenthesis. To deal with that wrong behavior, you merely declare the EOT first and append a single question mark. The question mark fools IE into thinking the rest of the string is a query string and loads just the EOT file. The other browsers follow the spec and select the format they need based on the src cascade and the format hint.

So the part that's necessary is the ?; I imagine the #iefix is just a semantic line for programmers that isn't interpreted by the browser in any particular way.

Here's some more information if you would like: https://github.com/stubbornella/csslint/wiki/Bulletproof-font-face.

Share:
21,015

Related videos on Youtube

12japerk
Author by

12japerk

Updated on July 09, 2022

Comments

  • 12japerk
    12japerk almost 2 years

    I have a question about css @font-face. I'm using the following code from this website (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).

    @font-face {
    font-family: 'MyFontFamily';
    src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'), 
         url('myfont-webfont.woff') format('woff'), 
         url('myfont-webfont.ttf')  format('truetype'),
         url('myfont-webfont.svg#svgFontName') format('svg');
    }
    

    Why does the line "url('myfont-webfont.eot?#iefix')" have "#iefix" at the end?

  • 12japerk
    12japerk over 11 years
    Thanks. This helped clear some stuff up.
  • patridge
    patridge about 11 years
    If you use #iefix after the ?, you end the querystring and start the URL fragment. I don't know if it was intended, but it could potentially avoid an issue with the remaining urls hitting any browser/server querystring limitations.
  • aendra
    aendra almost 11 years
    Interesting. Upboated!
  • gbakernet
    gbakernet about 10 years
    For developers requiring, a cache buster strategy, using a rewrite rule or filename change are the only options, as file.eot?v1 will not work..
  • user1664043
    user1664043 almost 7 years
    Looking at the behavior of Font Awesome's css, it seems like newer IEs are still following the same parsing rules. With Fiddler, I see IE 11 dropping into the ../fonts/fontawesome-webfont.eot?#iefix&v=4.3.0 rule while Chrome and Firefox avoid it.