Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Foundations Web Typography Web Fonts

Why are there two "src:" declarations rather than one?

In the @font-face rule, why are there two "src:" declarations?

@font-face { font-family: "DroidSerifBold"; src: url('fonts/DroidSerif-Bold-webfont.eot'); src: url('fonts/DroidSerif-Bold-webfont.eot?#iefix') format('embedded-opentype'), url('fonts/DroidSerif-Bold-webfont.woff') format('woff'), url('fonts/DroidSerif-Bold-webfont.ttf') format('truetype'), url('fonts/DroidSerif-Bold-webfont.svg#DroidSerifBold') format('svg'); font-weight: bold; font-style: normal; }

Is it not allowed to be like this?

@font-face { font-family: "DroidSerifBold"; src: url('fonts/DroidSerif-Bold-webfont.eot'), url('fonts/DroidSerif-Bold-webfont.eot?#iefix') format('embedded-opentype'), url('fonts/DroidSerif-Bold-webfont.woff') format('woff'), url('fonts/DroidSerif-Bold-webfont.ttf') format('truetype'), url('fonts/DroidSerif-Bold-webfont.svg#DroidSerifBold') format('svg'); font-weight: bold; font-style: normal; }

Just curious so I'll be able to know for the future. Thanks!

1 Answer

Kyle,

All of the "src:" declarations are necessary for the rendering engines to pick out the type of web font file that best applies to the browser. It would make a lot of sense to have everything nested under one "src:" but this is kind of the fallout from the browser makers not being able to come to a consensus on how to implement web fonts.

Here's an article that explains more on @font-face.

I hope this helps!

Mark,

Thanks so much, I appreciate it!