Search code examples
cssfont-face

Can relative paths be used for @font-face src?


When using @font-face in CSS to use custom fonts, can I specify a relative path for the fonts. Say I have the following structure:

WebContent
 - css
    |- style01.css
    |- style02.css
    |- ...
 - fonts
    |- font01.ttf
    |- font01.ttf
    |- ...
 - images
    |- ...
 - js
    |- ...
 - index.html
 - *.html

Can I specify something similar to:

@font-face {
   font-family: 'font one';
   src: url('../fonts/font01.ttf');
}

since the above does not seem to work.


Solution

  • Seems the issue was that it doesn't like the single quotes ' around the name.