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?
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.