0

I have a bunch of CSS document, that has some @font-face rules, I want to check these @font-face which are used and which are not used in a HTML Document or Website. So, should I check these @font-faces used in it's defined CSS Document or all CSS Documents with inline Style tags in HTML Document?

The question is, this;

File Name: style.css

@font-face {
    font-family:'FontAwesome';
    src:url('../fonts/fontawesome-webfont.eot?v=4.7.0');
    src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'),
    url('../fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'),
    url('../fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'),
    url('../fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'),
    url('../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
    font-weight:normal;
    font-style:normal
}

/* This tag can use the @font-face, because this .any-class rule in same CSS document */
.any-class {
    font-family: 'FontAwesome',
    font-weight: normal;
}

File Name: another-style.css

/* Can this CSS Class use the @font-face in style.css ? */
.any-other-class {
    font-family: 'FontAwesome',
    font-weight: normal;
}

File Name: index.html

<html>
<head>
    <link rel="stylesheet" href="style.css">
    <style>
        /* Can this .custom-class CSS Selector use @font-face in style.css ? */
        .custom-class {
            font-family: 'FontAwesome',
            font-weight: normal
        }
    </style>
</head>
<body>
    <!-- Can this DOM Element use @font-face in style.css? -->
    <p style="font-family: 'FontAwesome'; font-weight: normal;">Hello!</p>
</body>
</html>
2
  • 1
    Sadly, no the files are different so you wont be able to do this in CSS. You can try out SASS which allows you to create partial files and collectively form a CSS file. Commented Dec 29, 2018 at 10:00
  • 1
    @Joykal Infotech: That's not true. It will still work even when they are in separate files, as long as you include them all, whether using link in HTML as shown in the question or using @import in CSS. You don't need Sass for any of this. Commented Dec 29, 2018 at 10:18

1 Answer 1

1

Yes, everything you have here will just work, as long as you include style.css wherever you want to use your web font, e.g. the way you have done using link. Your @font-face rule, like any other CSS rule, does not have to appear in the same stylesheet as the CSS rules that reference it, or in any HTML with inline styles that reference it.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.