Techniqued- Technoloy, Review and Tutorials
  • Android
  • Freewares
  • Tutorial
  • Windows 11
  • macOS
No Result
View All Result
Techniqued- Technoloy, Review and Tutorials
  • Android
  • Freewares
  • Tutorial
  • Windows 11
  • macOS
No Result
View All Result
Techniqued- Technoloy, Review and Tutorials
No Result
View All Result

How to Embed or Use Web fonts on Websites using @Font-Face

Nirmal by Nirmal
February 7, 2012
in Tips and Tricks
2
Share on FacebookShare on Twitter

There are many popular fonts which are used in web designs and when they are used in CSS, it renders because the PC from where it is accessed have the fonts locally installed. But many of the popular fancy fonts which are available for download (open source) are not available in Windows by default and if you are to use these fonts in CSS, these wont show up in PCs which do not have them installed. To solve this problem you can use @font-face option, which basically asks the browser to use the fonts available on the server (of the website). But each browser has their own standards for using web fonts, so we will discuss on how to use them.

Font Face requires only few lines of CSS code to use them, but you need to have the fonts in different formats and then upload them to your website server, preferably in the same directory as the CSS files. Here is the code for @font-face;

@font-face{
font-family: 'MyWebFont';
src: url('WebFont.eot');
src: url('WebFont.eot?#iefix') format('embedded-opentype'),
url('WebFont.woff') format('woff'),
url('WebFont.ttf') format('truetype'),
url('WebFont.svg#webfont') format('svg');
}

Here, there are couple of simple things to understand, firstly the font-family directive in the first line, this specifies the name of the font you are going to use in the CSS. The next few lines are different versions of same font for different browsers.

Different web font formats:

There are basically four types of web font formats.

  • Embedded OpenType (EOT)
  • Scalable Vector Graphics (SVG)
  • TrueType/OpenType (TTF/OTF)
  • Web Open Font Format (WOFF)

Not all browsers support all formats and here is the break up of format supported by browser.

  • Internet Explorer only supports EOT (IE9 supports WOFF)
  • Mozilla browsers (3.5+) support OTF, WOFF and TTF
  • Safari and Opera support OTF, TTF and SVG
  • Chrome (4.0+) supports TTF, WOFF and SVG.

So in order to have your fonts rendered in all browsers, you need to embed fonts in all the 4 formats, which means for each new font you want to embed, it should be available in all the 4 formats and the code above helps you in the purpose. Now that you have written the @font-face in your CSS (insert this code at the starting), you need to make sure that your font is available in all the four formats and uploaded to your server.

Now you can use this web font in your stylesheet (CSS) file;

p { font-family: 'MyWebFont', Arial, sans-serif; }

Make sure you use the same name as mentioned in the font-face.

Where to get fonts in all the formats:

If you are wondering where to get these fonts in various formats, Font Squirrel has hundreds of font-face kits available for free download. These font face kits contain fonts in all the formats along with sample code for you to embed them easily.

Font face kits

If you have the fonts available, you can use Font Squirrel @font-face kit generator to create the kit.

Font-face generator

You can also use the awesome Google Fonts directory to embed all the fonts available there. The fonts available in Google Fonts directory are open source and needs no licensing. The advantage of using Google Fonts is that you do not have to worry about hosting the fonts as Google hosts all of them on their server.

Licensing Issues:

Although using this method, you can use any font available in the web, but make sure you use only the open source ones as there might be licensing issues. If you need to use @font-face for licensed fonts, you can check out paid services like TypeKit.

So next time you design your blog or website, try using the awesome web fonts rather than going for traditional fonts.

With inputs from Themeforest.

Tags: FontsTipsTricksWebfontsWebsites
ShareTweetSendSend
Previous Post

Automatically Set “Featured Image” for New and Old Posts in WordPress

Next Post

Google Releases Chrome for Android Beta

Related Posts

Tips and Tricks

Can I Run Windows 11 without Activating

June 14, 2024
Social Networks

How to Change your Instagram Name

May 12, 2024
Social Networks

How To View Your Instagram Reels Watch History

May 11, 2024
Social Networks

How To Post Longer Videos On Instagram

May 6, 2024
Social Networks

How to Find Who Unfollowed you on Instagram

December 9, 2023
Social Networks

How to Download Instagram Reels [Official Method]

November 28, 2023

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Latest Articles

How to Fix “Installation can’t continue” when trying to Update Nvidia Graphics Drivers

Download Windows 11 24H2 ISO (Offline Installer)

Can I Run Windows 11 without Activating

How to Use Snapchat on PC

How to Delete YouTube Search and Watch History on iPhone

How to Use Energy Saver on Windows 11

Techniqued- Technoloy, Review and Tutorials

© 2021 Techniqued - Technology, Tips, Tricks and Reviews

Navigate Site

  • About Us
  • Advertise with us
  • Contact Us
  • Copyright Policy
  • Disclaimer

Follow Us

No Result
View All Result
  • Android
  • Freewares
  • Tutorial
  • Windows 11
  • macOS

© 2021 Techniqued - Technology, Tips, Tricks and Reviews

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.