Stefan Gum
Stefan Gum

Reputation: 67

font family works only in html file

i load an extra font-style. but when i want to use this font-style, it works only in the html-file and not in the extra css-file.

[css]

    @font-face {
        font-family: sensation;
        src: url('./font/sansation_regular-webfont.eot');
        src: url('./font/sansation_regular-webfont.eot?#iefix') format('embedded-opentype'),
             url('./font/sansation_regular-webfont.woff2') format('woff2'),
             url('./font/sansation_regular-webfont.woff') format('woff'),
             url('./font/sansation_regular-webfont.ttf') format('truetype'),
             url('./font/sansation_regular-webfont.svg#sansation_regular-webfont') format('svg');
        font-weight: normal;
        font-style: normal;

    }   

When i use this part in the css file, so it's not possible to set the "font-Family" in the css file or html file.

When i use this part in the html file with ... It works only in the html file?

What's wrong?

Upvotes: 0

Views: 72

Answers (1)

hungerstar
hungerstar

Reputation: 21675

You're probably using the wrong path to your font files. Paths used in a CSS file are relative to the CSS file.

Given the following folder structure:

/index.html
    /css/style.css
    /js/script.js
    /font/font.eot
    /font/font.woff

Your style.css would use ../font/ to reach the font files where index.html would use font/ to reach the font files.

Upvotes: 1

Related Questions