user1623722
user1623722

Reputation:

@font-face working in one file, not in another

I've got a custom font setup on my site using @font-face in my stylesheet. It works just fine on my main page, but if I try to read the same stylesheet through another html file in a different directory, all of the styling will work fine except for the font.

The stylesheet (style.css) and font are in a /style/ directory. The html file is in a sub-directory, and I'm reading the stylesheet using this:

<link href = "../style.css" type = "text/css" rel = "stylesheet"/>

Again, it'll use all of the styling except the custom font. Why's that?

Upvotes: 0

Views: 81

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324650

You should always use either absolute URLs (with the full domain name and everything), or URLs relative to the domain root (/path/to/font.ttf) to prevent confusion as to whether the font is being loaded relative to the stylesheet or the document.

Upvotes: 1

Related Questions