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

Sanjar Ergashev
Sanjar Ergashev
2,626 Points

Google Fonts

When using google fonts, why do we need to copy a link to html file? Example: link href='http://fonts.googleapis.com/css?family=Alegreya+Sans' rel='stylesheet' type='text/css'

Why adding just " font-family: 'Alegreya Sans', sans-serif; " to CSS file and link it to html is not enough?

3 Answers

James Barnett
James Barnett
39,199 Points

When referring to fonts we are actually talking about the actual files that exist on the your computer. There is a file on your computer of ever font that is shown in any application. You add additional fonts by getting additional font files. You have to download these from somewhere before you can use them, that's what the linked file is for when using a Google web font.

Dean Yeong
Dean Yeong
10,053 Points

One of the method to use an alternate font is to have your font file downloaded in your document and link them into your html or stylesheet.

Google Fonts don't provide the font file (example: .ttf and .otf) to download and the link with be the link to use the Google Fonts in your html. Therefore, your font will not work offline when you are using Google Fonts.

Sanjar Ergashev
Sanjar Ergashev
2,626 Points

Thanks a lot. That clarifies.