Home >Web Front-end >CSS Tutorial >How Can I Import Google Web Fonts into My CSS File?
Importing Google Web Fonts into CSS files can enhance the aesthetics of your website. However, the absence of direct access to the
section in certain CMS environments may seem limiting. Nonetheless, there is a solution to seamlessly incorporate these fonts within your CSS file.The @import directive proves to be an effective method for importing Google Web Fonts. For instance, to include the font "Open Sans" into your CSS file, use the following syntax:
@import url('https://fonts.googleapis.com/css?family=Open+Sans&display=swap');
Remember to replace "Open Sans" with your desired font name. If the font name consists of multiple words, encode each word with a plus sign ( ), as shown in the example above.
Position the @import directive at the beginning of your CSS file, before implementing any rules. Google Fonts offers an automated method for creating the @import directive. Simply select a font, click the ( ) icon, and expand the "1 Family Selected" container.
Go to the "Customize" tab to refine your options, then switch to the "Embed" tab. Under "Embed Font," select "@import." Copy the CSS displayed within the