HTML CSS Exercise: Use Google Font
Solution:
HTML Code:
Explanation:
- This HTML code loads and applies the Google Font 'Indie Flower' to a paragraph element.
- The font is first linked in the head section of the HTML using a link tag, which fetches the font stylesheet from Google Fonts.
- Within the style tag, the font-family property is set to 'Indie Flower' for paragraphs, with a fallback to generic cursive fonts.
- Additionally, a script is included to load the font using the Web Font Loader provided by Google Fonts. This script is dynamically created and inserted into the document just before the closing body tag.
- The WebFontConfig object specifies the fonts to load, in this case, 'Indie Flower' with the Latin character set.
- The Web Font Loader script dynamically loads the font from the Google Fonts API asynchronously, improving page load performance.
- The comments provide instructions on how to use Google Fonts, including selecting a font, obtaining the code, and adding it to a website.
Live Demo:
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.