Search code examples
htmlcssfontsfont-face

font family query not displaying


I am trying this code to change the font. to the desired value, all the files of the font are saved in the same directory as css and html files. i am not able to find the error

@font-face {

    font-family:'newfont';
    src:url('../website/fonts/kulminoituva.eot');
    src:url('../website/fonts/kulminoituva.eot?#iefix') format('embedded-opentype'),
        url('../website/fonts/kulminoituva.woff') format('woff'),
        url('../website/fonts/kulminoituva.ttf') format('truetype');
    font-weight:normal;
    font-style:normal;
}

and the code while calling

ul li {
    font-family: 'newfont', helvetica, sans-serif;
}

update

I got this runned, after just giving the file name. without any file path. the bracket automatically detects the font. thanks to @Calvt and appleElmi


Solution

  • This has to be a reference issue, as @CalvT was alluding to. In the description, you mention

    all the files of the font are saved in the same directory as css and html files

    however, the @font-face declaration is indicating the fonts are in the parent directory (..), under /website/fonts

    Check the Developer Tools of the browser and make sure there are no errors indicating:

    Failed to load resource: net::ERR_FILE_NOT_FOUND

    If the fonts are saved in the same directory as css and html files, under a folder called website, then @font-face declaration should be

    @font-face {
        font-family:'newfont';
        src:url('website/fonts/kulminoituva.eot');
        src:url('website/fonts/kulminoituva.eot?#iefix') format('embedded-opentype'),
            url('website/fonts/kulminoituva.woff') format('woff'),
            url('website/fonts/kulminoituva.ttf') format('truetype');
        font-weight:normal;
        font-style:normal;
    }
    

    If they are saved in the same directory as css and html files under a folder called fonts, then remove website/ from your @font-face declaration