If you're looking for ways to add unique fonts to your webpage, one great option is to explore Google Fonts.
To easily incorporate fonts using links, you can simply link the desired font from Google in the <head>
section :
<head>
<link href="https://fonts.googleapis.com/css?family=Tangerine" rel="stylesheet">
</head>
Then, in your CSS, you would specify the font for your element like this:
YourClassHere {
font-family: 'Tangerine', cursive;
}
If you prefer to include the font directly in your CSS code, you can use the @import
attribute as shown below:
YourClassHere {
@import url('https://fonts.googleapis.com/css?family=Tangerine');
font-family: 'Tangerine', cursive;
}
For more detailed instructions on utilizing Google Fonts, refer to:
https://developers.google.com/fonts/docs/getting_started
NOTE: If you want to download a font and use it locally for offline coding, there's another approach in CSS.
After downloading the font of your choice, place it in your project folder and update your CSS with the following steps:
Begin by defining the font using the @font-face
attribute :
@font-face {
font-family: NameYourFontHere;
src: url(TheNameOfTheFontYouDownloadedHere.woff); //Make sure to specify the font type at the end
}
You can then use the font after declaring it as shown above :
div {
font-family: NameYourFontHere;
}
Resources for understanding the @font-face
rule :
https://www.w3schools.com/cssref/css3_pr_font-face_rule.asp
Information on the @import
rule :
https://www.w3schools.com/cssref/pr_import_rule.asp
I hope this explanation proves helpful for your font styling needs.