4

I'd like to add a new font from my "Styles" folder, of type .ttf to a page. What is the CSS code to change all the text font to that one?

I think it is just a matter of syntax becuase I know this works fine:

body {font-family: verdana;}

So basically, how to point that to my font file?

1
  • Are all your users going to have that font installed on their machines as well? Commented Jul 26, 2012 at 16:44

3 Answers 3

7

I believe you are looking for src attribute that font-face supports. Please see url for more knowledge http://www.w3.org/TR/css3-webfonts/#src-desc

<style type="text/css">
@font-face {
    font-family: "The Example Font";
    src: url(http://www.examplefonts.com/example.ttf) format("truetype");
}
div.ExampleFont { 
    font-family: "The Example Font", Verdana;
}
</style>
<div class="ExampleFont ">I am using the Example Font</div>
Sign up to request clarification or add additional context in comments.

1 Comment

Yes that's the one. I remembered using it before but could not remember how to call it. Thanks
0

You can't reference font files from Web applications. You can only use fonts that are either guaranteed to be installed on all machines already or by using something like Google Web Fonts. Then, you would use CSS, like you already have to apply the font using CSS selectors.

Listing of Web safe fonts

2 Comments

See @font-face's announcement about Google Web Font. @font-face is bowing out of the business.
Though, a downvote would probably be accurate as my statement of "You can't reference font files" is incorrect. You can if you generate the EOT and TTF files necessary for IE and other browsers, then use the @font-face rule. I think this is what Google Web Fonts is doing for you, however, and you just @import their CSS.
0

Microsoft has a Web Embedding Font Tool that will let you embed fonts. Here is a tutorial on how to use it too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.