3

I am testing html localy with notepad++ (not created a site yet) and I am trying to use a custom downloaded font. So, I have downloaded a ttf font and placed it under a folder that also contains the html file. Then I use

<html>
<head>
<style> 
@font-face {
  font-family: myFirstFont;
  src: url('C:\Users\Jon\Desktop\zz\clights.ttf')  format('truetype');
}

div {
    font-family: myFirstFont;
}
</style>
</head>
<body>

<div>Test123</div>

</body>
</html>

But that doesn't seem to work. I have viewed many answers but they all refer to adding a font to the contents of your site but I am testing html localy... How can I use a custom font this way? Ty

4
  • If the font directory is in the same directory as the html file you can just use url('zz\clights.ttf') Commented Mar 2, 2017 at 17:11
  • If the font file is in same folder as your html file is, then you do not need to write entire path in url. Just write the file name. Commented Mar 2, 2017 at 17:18
  • Maybe you find an answer here: stackoverflow.com/questions/10795708/… Commented Mar 2, 2017 at 17:20
  • Tried all the combinations even without the full path but still no font appears ;/ Commented Mar 2, 2017 at 17:30

1 Answer 1

5

You don't need the entire filepath. Since its in the same folder, simply use url('zz/fontname.ttf)

Or if the ttf file is in the same directory as the index.html file, then drop the 'zz'

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.