Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Font Face "?#iefix" [duplicate]

Tags:

css

font-face

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?

like image 898
12japerk Avatar asked Jan 08 '13 02:01

12japerk


People also ask

What is CSS font face?

The @font-face CSS at-rule specifies a custom font with which to display text; the font can be loaded from either a remote server or a locally-installed font on the user's own computer.

What is the font face rule?

The @font-face rule allows custom fonts to be loaded on a webpage. Once added to a stylesheet, the rule instructs the browser to download the font from where it is hosted, then display it as specified in the CSS.


1 Answers

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.

like image 129
Shrey Gupta Avatar answered Oct 05 '22 00:10

Shrey Gupta