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 trialGarrett Levine
20,305 Pointssrc: not working properly
I am coding exactly as instructed in the video in regards to @font-face and for some reason as soon as i type src: url(....) the 'src' part goes red, not allowing the font face to be linked. I am wondering why this is happening? It even happens in an unrelated CSS file (when I open the CSS file that accompanies the text face files).
this is the code I have typed (straight from following the video).
@font-face {
font-family: "droid_serifbold";
src:url('fonts/DroidSerif-Bold-webfont.eot');
src:url('fonts/DroidSerif-Bold-webfont.eot?#iefix') format('emdedded-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;
}
5 Answers
Wayne Priestley
19,579 PointsHey Garrett,
Want to try this please.
@font-face {
font-family: "droid_serifbold";
src: url('fonts/DroidSerif-Bold-webfont.eot');
src: url('fonts/DroidSerif-Bold-webfont.eot?#iefix') format('emdedded-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;
}
Guil Hernandez
Treehouse TeacherHi Garrett Levine,
For some reason, Workspaces highlights src
in red, even thought it's perfectly valid code. Your code looks fine. My assumption, at this point, is your file path. Try adding ../
before the fonts
directory in your path.
Ex: src: url('../fonts/DroidSerif-Bold-webfont.eot');
Garrett Levine
20,305 PointsI checked my file path, and it should be correct. I am now trying this in another workspace file, so I did already have the "../font/" file path. Everything seems like it should working fine, but it's okay. I've continued on with the lessons regardless. I'll just rely on google-fonts more. ;)
Garrett Levine
20,305 PointsThank you! Though the problem still remains that the 'src' is red red red. when I remove it from the @font-face { } it is no longer red (but of course is useless).
Wayne Priestley
19,579 PointsHey Garrett,
Try:
src: url('fonts/DroidSerif-Bold-webfont.eot');
Hope this helps.
Garrett Levine
20,305 Pointsunfortunately changes nothing. I also tried pasting that bit of code into another black CSS file in the workspace, and the same problem occurs with the 'src' being entirely red in workspace.
Wayne Priestley
19,579 PointsIt might be worth logging out then back in, maybe restarting the browser or trying a different one.
Wayne Priestley
19,579 PointsIt has to be a workspaces issue, the code validates.
Garrett Levine
20,305 Pointstried logging out AND in a different browser. It remains unsolved, but I feel better knowing my code was okay (probably).
Garrett Levine
20,305 PointsGarrett Levine
20,305 Pointsstill not working unfortunately. this is what is happening in my document.
Wayne Priestley
19,579 PointsWayne Priestley
19,579 PointsIf you paste the code I put in my post into css validator it shows no errors..
hmmm
Garrett Levine
20,305 PointsGarrett Levine
20,305 Pointsright? it's weird! it's in all my workspaces . the above image is done with your code.
Wayne Priestley
19,579 PointsWayne Priestley
19,579 PointsWayne Priestley
19,579 PointsWayne Priestley
19,579 PointsThe screenshot i posted was from Sublimetext not workspaces.
Garrett Levine
20,305 PointsGarrett Levine
20,305 PointsI'm tempted to chalk it up to a workspaces issue, but I don't wanna take the easy way out.