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

src: 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

Hey 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;

}

still not working unfortunately. this is what is happening in my document.

src prblm

If you paste the code I put in my post into css validator it shows no errors..

hmmm

right? it's weird! it's in all my workspaces . the above image is done with your code.

alt text

The screenshot i posted was from Sublimetext not workspaces.

I'm tempted to chalk it up to a workspaces issue, but I don't wanna take the easy way out.

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi 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');

I 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. ;)

Guil Hernandez
STAFF
Guil Hernandez
Treehouse Teacher

Hi Garrett Levine,

It looks like you're missing the ; after format ('svg')

Hope this helps. :)

Thank 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).

Hey Garrett,

Try:

src: url('fonts/DroidSerif-Bold-webfont.eot');

Hope this helps.

unfortunately 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.

It might be worth logging out then back in, maybe restarting the browser or trying a different one.

It has to be a workspaces issue, the code validates.

tried logging out AND in a different browser. It remains unsolved, but I feel better knowing my code was okay (probably).