Search code examples
cssexternalfont-face

External fonts style sheet


Is there anyway to include a css type file with @font-face's already saved. I have may different fonts that i have downloaded that i want to use across different sites so it would be good to have one style sheet that i can just refer to and pick a font from. I tried doing this with a css file and linking it to the html document but it didn't work. Do I have to link it to the css instead and if so how do I do that?

Many thanks,

James


Solution

  • If I understood correctly... Imagine you have your site in www.yourdomain.com/index.html, your style.css file in www.yourdomain.com/css/style.css and your fonts in www.yourdomain.com/fonts/

    Your index.html will say: <link href="css/style.css" rel="stylesheet" type="text/css" />

    And your css will say something like: url('../fontNamettf') format('truetype'),

    Now, if you have an HTML somewhere else (say, new.html), all you need to do is call that style.css using the absolute route, and it will find the fonts, because they are in the same domain / folder as the stylesheet.

    Your new.html would then say: <link href="www.yourdomain.com/css/style.css" rel="stylesheet" type="text/css" />