Home >Web Front-end >CSS Tutorial >How Can I Embed Google Web Fonts in CSS Without Accessing the ``?
Embedding Google Web Fonts in CSS Without Modifying the Head
Importing web fonts directly into a CSS file is a solution for customizing web pages within a CMS where direct access to the document head is unavailable. The @import method provides a way to achieve this:
@import url('https://fonts.googleapis.com/css?family=Open+Sans&display=swap');
Here, "Open Sans" is the imported font, so replace it with your preferred choice. For font names with multiple words, encode them using the symbol, as demonstrated above.
To ensure proper implementation, place the @import statement at the beginning of your CSS, before any other rules.
Google Fonts offers a simplified way to generate the necessary @import directive. After selecting a font, click the ( ) icon and navigate to "Embed." Choose the "@import" option under "Embed Font" and copy the CSS between the