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 trialStefan Cutajar
7,747 PointsDownloaded web fonts
Hi, I'm trying to add some fonts to a web page and would like to add some fonts that I downloaded how can I do that please?
1 Answer
Matthew Long
28,407 PointsYou're off to a good start knowing you should use @font-face
! The basic syntax is:
@font-face {
font-family: 'name-you-give-your-font';
src: url(/path-to-your-font/font.otf);
}
Now to use this font on your site, you use font-family
:
body {
font-family: 'name-you-give-your-font', sans-serif;
}
Note, I put it on the body
element, but you can use it wherever best fits your project. Also, it's a good idea to have a fallback font. In the example above the fallback font is sans-serif
.
Hopefully this clears things up for you!
Stefan Cutajar
7,747 PointsStefan Cutajar
7,747 PointsThanks I've managed :) was a bit confused since the fonts are on my computer not on the net.
B.B. Groeneveld
2,826 PointsB.B. Groeneveld
2,826 PointsHey Matthew, I see you are using an .otf file. Guil doesn't mark this file. Is it appropiate to use this or should we only use eot's, woff's and ttf's as in the video?
Matthew Long
28,407 PointsMatthew Long
28,407 PointsTechnically you can use whatever gets the job done. But probably a good idea to stick with a format Guil recommends if possible.