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 trialRoutine Poutine
26,050 Points@font-face vs. <link href= Google Fonts>
Hi,
I usually use Google Fonts for extras, and past the CDN's address in <link>.
- Is @font-face another way to do this?
- Is it more or less common than using <link>?
- When is it the preferred method?
Best,
Matt
1 Answer
Adam Pengh
29,881 PointsIf you're using linking to the Google Font CDN, you do not need to use @font-face. For example, if you put this URL in your browser, you will see that the @font-face declarations. https://fonts.googleapis.com/css?family=Roboto
You only need to use @font-face if you are hosting fonts locally. Then you would need to use @font-face to declare the path to load the fonts. Example:
@font-face {
font-family: 'Custom Font';
font-style: normal;
font-weight: 400;
src:
local('Custom'),
local('Custom-Regular'), url(/path/to/custom/font.woff2) format('woff2'),
local('Custom-Regular'), url(/path/to/custom/font.woff) format('woff');
}