Connected Tutorial(This question is a follow-up to this tutorial):
How To Define Custom Fonts in CSS with @font-face and font-displayI become so very lost when I try to put my mind around what value to use when specifying the url attribute of the @font-face Rule. Please, I would like to know:
(Pray, I hope I have not sounded like a complete idiot.) Do help me.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello there,
The url attribute in the @font-face rule specifies the source of the custom font files. It can be a URL to a font file hosted on a website, or it can be a file path on your local machine, depending on how you want to manage your fonts. Let me explain both scenarios:
url attribute to the URL of the font file on that website. For example:- @font-face {
- font-family: 'MyCustomFont';
- src: url('https://example.com/fonts/myfont.woff2') format('woff2');
- }
In this case, the custom font will be downloaded by the user’s browser from the specified URL when they visit your website. This approach is often used when you want to use a font that’s available on a web font service or another website.
- @font-face {
- font-family: 'MyCustomFont';
- src: url('/fonts/myfont.woff2') format('woff2');
- }
When using a locally hosted font, the url attribute should point to the font file’s location on your server or relative to your website’s root directory. This way, the font file will be fetched from your server when someone visits your website.
Hope that this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.